Skip to content

MLE-23146 Address compile warnings in src/main/java #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 31 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,50 @@
// used for that. So we have to add the properties plugin to the buildscript classpath and then apply the properties
// plugin via subprojects below.
buildscript {
repositories {
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.saliman:gradle-properties-plugin:1.5.2"
}
repositories {
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.saliman:gradle-properties-plugin:1.5.2"
}
}

subprojects {
apply plugin: "net.saliman.properties"
apply plugin: 'java'
apply plugin: "net.saliman.properties"
apply plugin: 'java'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
}

// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
java {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
java {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

configurations {
testImplementation.extendsFrom compileOnly
}
configurations {
testImplementation.extendsFrom compileOnly
}

repositories {
mavenLocal()
mavenCentral()
}
repositories {
mavenLocal()
mavenCentral()
}

test {
systemProperty "file.encoding", "UTF-8"
systemProperty "javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl"
}

// Until we do a cleanup of javadoc errors, the build (and specifically the javadoc task) fails on Java 11
// and higher. Preventing that until the cleanup can occur.
javadoc.failOnError = false
// and higher. Preventing that until the cleanup can occur.
javadoc.failOnError = false

// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
// Until then, it's just a lot of noise.
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
// Until then, it's just a lot of noise.
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public void close() {
}
items = null;
}
@Override
protected void finalize() throws Throwable {
close();
super.finalize();
}
}

class InputItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private RequestParameters initParams(String optionsName, long start) {
params.add("format", "xml");
params.add("start", String.valueOf(start));

if (optionsName != null && optionsName.length() > 0)
if (optionsName != null && !optionsName.isEmpty())
params.add("options", optionsName);
if (pageLength != QueryManager.DEFAULT_PAGE_LENGTH)
params.add("pageLength", String.valueOf(pageLength));
Expand Down Expand Up @@ -163,11 +163,5 @@ public void close() {
searchResult = null;
}
}

@Override
protected void finalize() throws Throwable {
close();
super.finalize();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public void jsMasstransformReplaceDelete() throws Exception {
assertFalse(isFailureCalled.get());
assertTrue(flag.get());

Set<String> urisList = Collections.synchronizedSet(new HashSet<String>());
Set<String> urisList = Collections.synchronizedSet(new HashSet<>());

assertTrue(urisList.isEmpty());
QueryBatcher queryBatcher = dmManager.newQueryBatcher(new StructuredQueryBuilder()
Expand Down Expand Up @@ -622,7 +622,7 @@ public void stopTransformJobTest() throws Exception {
Set<String> successUris = Collections.synchronizedSet(new HashSet<>());
Set<String> failedUris = Collections.synchronizedSet(new HashSet<>());

List<Throwable> failures = new Vector<>();
List<Throwable> failures = Collections.synchronizedList(new ArrayList<>());

ApplyTransformListener listener = new ApplyTransformListener()
.withTransform(transform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void testAndWordQuery() throws Exception
qb.awaitCompletion();
} catch (Exception ex) {
batchIllegalState.append(ex.getMessage());
System.out.println("Exceptions buffer from empty withCriteria : " + batchIllegalState.toString());
System.out.println("Exceptions buffer from empty withCriteria : " + batchIllegalState);
assertTrue( batchIllegalState.toString().contains("Criteria cannot be an empty string"));
}
} catch (Exception e) {
Expand Down Expand Up @@ -649,7 +649,7 @@ public void testRawCtsQuery() throws IOException, InterruptedException {
dmManager.startJob(queryBatcher1);
queryBatcher1.awaitCompletion(1, TimeUnit.MINUTES);

System.out.println("Batch Results are : " + batchResults.toString());
System.out.println("Batch Results are : " + batchResults);
System.out.println("File name is : " + filenames[4]);
assertTrue( batchResults.toString().contains("cts-" + filenames[4]));

Expand Down Expand Up @@ -827,7 +827,7 @@ public void testQueryBatcherQueryFailures() throws IOException, InterruptedExcep
if (!batchFailResults.toString().isEmpty() && batchFailResults.toString().contains("Exceptions")) {
// Write out and assert on query failures.
System.out.println("Exception Buffer contents on Query Exceptions received from callback onQueryFailure");
System.out.println(batchFailResults.toString());
System.out.println(batchFailResults);
// Remove this failure once there are no NPEs and doa asserts on various
// counters in failure scenario.
fail("Test failed due to exceptions");
Expand Down Expand Up @@ -873,7 +873,7 @@ public void testQueryBatcherCallbackClient() throws IOException, InterruptedExce

// Flush
batcher.flushAndWait();
StringBuffer batchFailResults = new StringBuffer();
StringBuilder batchFailResults = new StringBuilder();
String expectedStr = "Vannevar Bush wrote an article for The Atlantic Monthly";

QueryManager queryMgr = client.newQueryManager();
Expand Down Expand Up @@ -1905,7 +1905,7 @@ public void testDifferentQueryTypes() throws Exception
StructuredQueryDefinition queryRangedef = qb.range(qb.element("popularity"), "xs:int", Operator.GE, 4);
QueryBatcher queryBatcher2 = dmManagerTmp.newQueryBatcher(queryRangedef);
// StringBuilder batchRangeResults = new StringBuilder();
List<String> batchRangeResults = new ArrayList<String>();
List<String> batchRangeResults = new ArrayList<>();
StringBuilder batchRangeFailResults = new StringBuilder();

queryBatcher2.onUrisReady(batch -> {
Expand Down Expand Up @@ -1938,7 +1938,7 @@ public void testDifferentQueryTypes() throws Exception

StructuredQueryDefinition valuequeyDef = qb.value(qb.elementAttribute(qb.element(new QName("http://cloudbank.com", "price")), qb.attribute("amt")), "0.1");
QueryBatcher queryBatcher3 = dmManagerTmp.newQueryBatcher(valuequeyDef);
List<String> batchValueResults = new ArrayList<String>();
List<String> batchValueResults = new ArrayList<>();
StringBuilder batchvalueFailResults = new StringBuilder();

queryBatcher3.onUrisReady(batch -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void testJobReportTimes() throws Exception {
querydef.setCriteria("k and v");

AtomicInteger successDocs = new AtomicInteger();
StringBuffer failures = new StringBuffer();
StringBuilder failures = new StringBuilder();

QueryBatcher deleteBatcher = dmManager.newQueryBatcher(querydef)
.withBatchSize(5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ public void run() {
if (!threadMap.containsKey(poolname)) {
threadMap.put(poolname, 1);
} else {
threadMap.put(poolname, new Integer(threadMap.get(poolname) + 1));
threadMap.put(poolname, threadMap.get(poolname) + 1);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testPartialUpdateXML() throws IOException {

// Flip the boolean values for both screen types
patchBldrBool.replaceValue("/resources/screen[@name=\"screen_small\"]", false);
patchBldrBool.replaceValue("/resources/screen[@name=\"adjust_view_bounds\"]", new Boolean(true));
patchBldrBool.replaceValue("/resources/screen[@name=\"adjust_view_bounds\"]", true);

DocumentPatchHandle patchHandleBool = patchBldrBool.build();
docMgr.patch(xmlDocId, patchHandleBool);
Expand Down Expand Up @@ -174,7 +174,7 @@ public void testPartialUpdateJSON() throws IOException {

// Replace original to false and modified to true.
patchBldrBool.replaceValue("$.employees[5].original", false);
patchBldrBool.replaceValue("$.employees[1].modified", new Boolean(true));
patchBldrBool.replaceValue("$.employees[1].modified", true);

DocumentPatchHandle patchHandleBool = patchBldrBool.build();
docMgr.patch(docId, patchHandleBool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private Iterable<TypedRow> getTypedRows(QueryBatch batch) throws IOException {
jp.nextToken();
if ( jp.currentToken() == JsonToken.END_OBJECT) {
logger.warn("No documents found for this batch");
return new ArrayList<TypedRow>();
return new ArrayList<>();
} else {
return new Iterable<TypedRow>() {
public Iterator<TypedRow> iterator() {
Expand Down Expand Up @@ -242,7 +242,7 @@ private TypedRow getOneTypedRow(JsonParser jp) {
if ( jp.currentToken() != JsonToken.FIELD_NAME ) {
throw new MarkLogicIOException("Expected a uri for next template result");
}
uri = jp.getCurrentName();
uri = jp.currentName();
if ( jp.nextToken() != JsonToken.START_ARRAY ) {
throw new MarkLogicIOException("Expected an array of rows");
}
Expand All @@ -268,7 +268,7 @@ private TypedRow getOneTypedRow(JsonParser jp) {
if ( "triple".equals(jp.nextFieldName()) ) {
throw new MarkLogicIOException("Expected a row but we got a triple. We don't support triples");
}
if ( !"row".equals(jp.getCurrentName()) || jp.nextToken() != JsonToken.START_OBJECT ) {
if ( !"row".equals(jp.currentName()) || jp.nextToken() != JsonToken.START_OBJECT ) {
throw new MarkLogicIOException("Expected row to start");
}
while (!"data".equals(jp.nextFieldName())) {
Expand All @@ -281,18 +281,18 @@ private TypedRow getOneTypedRow(JsonParser jp) {
while (jp.nextToken() == JsonToken.FIELD_NAME) {
JsonToken valueType = jp.nextToken();
if ( valueType == JsonToken.VALUE_STRING ) {
row.put(jp.getCurrentName(), pb.xs.string(jp.getText()));
row.put(jp.currentName(), pb.xs.string(jp.getText()));
} else if ( valueType == JsonToken.VALUE_NUMBER_INT ) {
row.put(jp.getCurrentName(), pb.xs.integer(jp.getIntValue()));
row.put(jp.currentName(), pb.xs.integer(jp.getIntValue()));
} else if ( valueType == JsonToken.VALUE_NUMBER_FLOAT ) {
row.put(jp.getCurrentName(), pb.xs.floatVal(jp.getFloatValue()));
row.put(jp.currentName(), pb.xs.floatVal(jp.getFloatValue()));
} else if ( valueType == JsonToken.VALUE_TRUE || valueType == JsonToken.VALUE_FALSE ) {
row.put(jp.getCurrentName(), pb.xs.booleanVal(jp.getBooleanValue()));
row.put(jp.currentName(), pb.xs.booleanVal(jp.getBooleanValue()));
} else if ( valueType == JsonToken.VALUE_NULL ) {
row.put(jp.getCurrentName(), null);
row.put(jp.currentName(), null);
} else {
throw new MarkLogicIOException(
"Unexpected value type for column \"" + jp.getCurrentName() + "\"");
"Unexpected value type for column \"" + jp.currentName() + "\"");
}
}
if ( jp.currentToken() != JsonToken.END_OBJECT || jp.nextToken() != JsonToken.END_OBJECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public HostAvailabilityListener withMinHosts(int numHosts) {
*
* @return this instance (for method chaining)
*/
public HostAvailabilityListener withHostUnavailableExceptions(Class<Throwable>... exceptionTypes) {
@SafeVarargs
public final HostAvailabilityListener withHostUnavailableExceptions(Class<Throwable>... exceptionTypes) {
hostUnavailableExceptions = new ArrayList<>();
for ( Class<Throwable> exception : exceptionTypes ) {
hostUnavailableExceptions.add(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ public Stream<T> split(JsonParser input) throws IOException {
* files.The splitFilename could either be provided here or in user-defined UriMaker.
* @return a stream of DocumentWriteOperation to write to database
*/
@SuppressWarnings("unchecked")
public Stream<DocumentWriteOperation> splitWriteOperations(JsonParser input, String splitFilename) {
if (input == null) {
throw new IllegalArgumentException("Input cannot be null");
}
count = 0;

this.splitFilename = splitFilename;
JSONSplitter.DocumentWriteOperationSpliterator spliterator =
JSONSplitter.DocumentWriteOperationSpliterator<T> spliterator =
new JSONSplitter.DocumentWriteOperationSpliterator<>(this, input);
return StreamSupport.stream(spliterator, true);
}
Expand Down Expand Up @@ -385,7 +386,7 @@ T getNextHandle() {
switch (currentToken) {
case FIELD_NAME:
key.pop();
key.push(jsonParser.getCurrentName());
key.push(jsonParser.currentName());
break;

case START_OBJECT:
Expand Down Expand Up @@ -556,7 +557,7 @@ public JsonToken nextToken() throws IOException {
}

maintainDepth();
return super.getCurrentToken();
return super.currentToken();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public Stream<DocumentWriteOperation> splitDocumentWriteOperations(Stream<Path>
return paths.flatMap(this::flatMapDocumentWriteOperations);
}

@SuppressWarnings("unchecked")
private Stream<? extends AbstractWriteHandle> flatMapHandles(Path path) {
String extension = getExtension(path);
Splitter splitter = lookupSplitter(extension);
Expand All @@ -119,6 +120,7 @@ private Stream<? extends AbstractWriteHandle> flatMapHandles(Path path) {
}
}

@SuppressWarnings("unchecked")
private Stream<DocumentWriteOperation> flatMapDocumentWriteOperations(Path path) {
String extension = getExtension(path);
Splitter splitter = lookupSplitter(extension);
Expand Down Expand Up @@ -153,6 +155,7 @@ private String getExtension(Path path) {
return matcher.group(1);
}

@SuppressWarnings("unchecked")
private Splitter<? extends AbstractWriteHandle> lookupSplitter(String extension) {
Splitter splitter = splitterMap.get(extension);
if (splitter == null && splitterMap.get(DEFAULT_SPLITTER_KEY) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public ProgressListener() {
* Use this constructor for when the total number of results isn't known ahead of time.
* @param consumers one or more callbacks for progress updates
*/
@SafeVarargs
public ProgressListener(Consumer<ProgressUpdate>... consumers) {
this(0, consumers);
}
Expand All @@ -65,6 +66,7 @@ public ProgressListener(Consumer<ProgressUpdate>... consumers) {
* @param totalResults the total number of results that is the processing goal
* @param consumers one or more callbacks for progress updates
*/
@SafeVarargs
public ProgressListener(long totalResults, Consumer<ProgressUpdate>... consumers) {
this.totalResults = totalResults;
for (Consumer<ProgressUpdate> consumer : consumers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public interface RowBatcher<T> extends Batcher {
* rows when more than one callback function is needed.
* @param listeners the success listeners
*/
void setSuccessListeners(RowBatchSuccessListener<T>... listeners);
@SuppressWarnings("unchecked")
void setSuccessListeners(RowBatchSuccessListener<T>... listeners);
/**
* Specifies the callback functions for errors when more than
* one callback function is needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ private static class DocumentWriteOperationSpliterator<T extends XMLWriteHandle>
super(xmlSplitter, input);
}
@Override
@SuppressWarnings("unchecked")
public boolean tryAdvance(Consumer<? super DocumentWriteOperation> action) {

T handle = (T) getNextHandle();
Expand Down
Loading