Skip to content

Commit c469ad7

Browse files
authored
Merge pull request #1809 from marklogic/feature/23146-compile-fixes
MLE-23146 Address compile warnings in src/main/java
2 parents 5846bae + 3245c2a commit c469ad7

File tree

51 files changed

+477
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+477
-477
lines changed

build.gradle

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,50 @@
44
// used for that. So we have to add the properties plugin to the buildscript classpath and then apply the properties
55
// plugin via subprojects below.
66
buildscript {
7-
repositories {
8-
maven {
9-
url = "https://plugins.gradle.org/m2/"
10-
}
11-
}
12-
dependencies {
13-
classpath "net.saliman:gradle-properties-plugin:1.5.2"
14-
}
7+
repositories {
8+
maven {
9+
url = "https://plugins.gradle.org/m2/"
10+
}
11+
}
12+
dependencies {
13+
classpath "net.saliman:gradle-properties-plugin:1.5.2"
14+
}
1515
}
1616

1717
subprojects {
18-
apply plugin: "net.saliman.properties"
19-
apply plugin: 'java'
18+
apply plugin: "net.saliman.properties"
19+
apply plugin: 'java'
2020

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

25-
// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
26-
java {
27-
sourceCompatibility = 1.8
28-
targetCompatibility = 1.8
29-
}
26+
// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.
27+
java {
28+
sourceCompatibility = 1.8
29+
targetCompatibility = 1.8
30+
}
3031

31-
configurations {
32-
testImplementation.extendsFrom compileOnly
33-
}
32+
configurations {
33+
testImplementation.extendsFrom compileOnly
34+
}
3435

35-
repositories {
36-
mavenLocal()
37-
mavenCentral()
38-
}
36+
repositories {
37+
mavenLocal()
38+
mavenCentral()
39+
}
3940

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

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

49-
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
50-
// Until then, it's just a lot of noise.
51-
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
50+
// Ignores warnings on param tags with no descriptions. Will remove this once javadoc errors are addressed.
51+
// Until then, it's just a lot of noise.
52+
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
5253
}

examples/src/main/java/com/marklogic/client/example/extension/BatchManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ public void close() {
142142
}
143143
items = null;
144144
}
145-
@Override
146-
protected void finalize() throws Throwable {
147-
close();
148-
super.finalize();
149-
}
150145
}
151146

152147
class InputItem {

examples/src/main/java/com/marklogic/client/example/extension/SearchCollector.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private RequestParameters initParams(String optionsName, long start) {
8686
params.add("format", "xml");
8787
params.add("start", String.valueOf(start));
8888

89-
if (optionsName != null && optionsName.length() > 0)
89+
if (optionsName != null && !optionsName.isEmpty())
9090
params.add("options", optionsName);
9191
if (pageLength != QueryManager.DEFAULT_PAGE_LENGTH)
9292
params.add("pageLength", String.valueOf(pageLength));
@@ -163,11 +163,5 @@ public void close() {
163163
searchResult = null;
164164
}
165165
}
166-
167-
@Override
168-
protected void finalize() throws Throwable {
169-
close();
170-
super.finalize();
171-
}
172166
}
173167
}

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/ApplyTransformTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public void jsMasstransformReplaceDelete() throws Exception {
550550
assertFalse(isFailureCalled.get());
551551
assertTrue(flag.get());
552552

553-
Set<String> urisList = Collections.synchronizedSet(new HashSet<String>());
553+
Set<String> urisList = Collections.synchronizedSet(new HashSet<>());
554554

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

625-
List<Throwable> failures = new Vector<>();
625+
List<Throwable> failures = Collections.synchronizedList(new ArrayList<>());
626626

627627
ApplyTransformListener listener = new ApplyTransformListener()
628628
.withTransform(transform)

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/StringQueryHostBatcherTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void testAndWordQuery() throws Exception
255255
qb.awaitCompletion();
256256
} catch (Exception ex) {
257257
batchIllegalState.append(ex.getMessage());
258-
System.out.println("Exceptions buffer from empty withCriteria : " + batchIllegalState.toString());
258+
System.out.println("Exceptions buffer from empty withCriteria : " + batchIllegalState);
259259
assertTrue( batchIllegalState.toString().contains("Criteria cannot be an empty string"));
260260
}
261261
} catch (Exception e) {
@@ -649,7 +649,7 @@ public void testRawCtsQuery() throws IOException, InterruptedException {
649649
dmManager.startJob(queryBatcher1);
650650
queryBatcher1.awaitCompletion(1, TimeUnit.MINUTES);
651651

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

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

874874
// Flush
875875
batcher.flushAndWait();
876-
StringBuffer batchFailResults = new StringBuffer();
876+
StringBuilder batchFailResults = new StringBuilder();
877877
String expectedStr = "Vannevar Bush wrote an article for The Atlantic Monthly";
878878

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

19111911
queryBatcher2.onUrisReady(batch -> {
@@ -1938,7 +1938,7 @@ public void testDifferentQueryTypes() throws Exception
19381938

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

19441944
queryBatcher3.onUrisReady(batch -> {

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/WriteBatcherJobReportTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public void testJobReportTimes() throws Exception {
333333
querydef.setCriteria("k and v");
334334

335335
AtomicInteger successDocs = new AtomicInteger();
336-
StringBuffer failures = new StringBuffer();
336+
StringBuilder failures = new StringBuilder();
337337

338338
QueryBatcher deleteBatcher = dmManager.newQueryBatcher(querydef)
339339
.withBatchSize(5)

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/WriteHostBatcherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ public void run() {
16971697
if (!threadMap.containsKey(poolname)) {
16981698
threadMap.put(poolname, 1);
16991699
} else {
1700-
threadMap.put(poolname, new Integer(threadMap.get(poolname) + 1));
1700+
threadMap.put(poolname, threadMap.get(poolname) + 1);
17011701
}
17021702
}
17031703
}

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/TestPartialUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testPartialUpdateXML() throws IOException {
9696

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

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

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

179179
DocumentPatchHandle patchHandleBool = patchBldrBool.build();
180180
docMgr.patch(docId, patchHandleBool);

marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExtractRowsViaTemplateListener.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private Iterable<TypedRow> getTypedRows(QueryBatch batch) throws IOException {
193193
jp.nextToken();
194194
if ( jp.currentToken() == JsonToken.END_OBJECT) {
195195
logger.warn("No documents found for this batch");
196-
return new ArrayList<TypedRow>();
196+
return new ArrayList<>();
197197
} else {
198198
return new Iterable<TypedRow>() {
199199
public Iterator<TypedRow> iterator() {
@@ -242,7 +242,7 @@ private TypedRow getOneTypedRow(JsonParser jp) {
242242
if ( jp.currentToken() != JsonToken.FIELD_NAME ) {
243243
throw new MarkLogicIOException("Expected a uri for next template result");
244244
}
245-
uri = jp.getCurrentName();
245+
uri = jp.currentName();
246246
if ( jp.nextToken() != JsonToken.START_ARRAY ) {
247247
throw new MarkLogicIOException("Expected an array of rows");
248248
}
@@ -268,7 +268,7 @@ private TypedRow getOneTypedRow(JsonParser jp) {
268268
if ( "triple".equals(jp.nextFieldName()) ) {
269269
throw new MarkLogicIOException("Expected a row but we got a triple. We don't support triples");
270270
}
271-
if ( !"row".equals(jp.getCurrentName()) || jp.nextToken() != JsonToken.START_OBJECT ) {
271+
if ( !"row".equals(jp.currentName()) || jp.nextToken() != JsonToken.START_OBJECT ) {
272272
throw new MarkLogicIOException("Expected row to start");
273273
}
274274
while (!"data".equals(jp.nextFieldName())) {
@@ -281,18 +281,18 @@ private TypedRow getOneTypedRow(JsonParser jp) {
281281
while (jp.nextToken() == JsonToken.FIELD_NAME) {
282282
JsonToken valueType = jp.nextToken();
283283
if ( valueType == JsonToken.VALUE_STRING ) {
284-
row.put(jp.getCurrentName(), pb.xs.string(jp.getText()));
284+
row.put(jp.currentName(), pb.xs.string(jp.getText()));
285285
} else if ( valueType == JsonToken.VALUE_NUMBER_INT ) {
286-
row.put(jp.getCurrentName(), pb.xs.integer(jp.getIntValue()));
286+
row.put(jp.currentName(), pb.xs.integer(jp.getIntValue()));
287287
} else if ( valueType == JsonToken.VALUE_NUMBER_FLOAT ) {
288-
row.put(jp.getCurrentName(), pb.xs.floatVal(jp.getFloatValue()));
288+
row.put(jp.currentName(), pb.xs.floatVal(jp.getFloatValue()));
289289
} else if ( valueType == JsonToken.VALUE_TRUE || valueType == JsonToken.VALUE_FALSE ) {
290-
row.put(jp.getCurrentName(), pb.xs.booleanVal(jp.getBooleanValue()));
290+
row.put(jp.currentName(), pb.xs.booleanVal(jp.getBooleanValue()));
291291
} else if ( valueType == JsonToken.VALUE_NULL ) {
292-
row.put(jp.getCurrentName(), null);
292+
row.put(jp.currentName(), null);
293293
} else {
294294
throw new MarkLogicIOException(
295-
"Unexpected value type for column \"" + jp.getCurrentName() + "\"");
295+
"Unexpected value type for column \"" + jp.currentName() + "\"");
296296
}
297297
}
298298
if ( jp.currentToken() != JsonToken.END_OBJECT || jp.nextToken() != JsonToken.END_OBJECT

marklogic-client-api/src/main/java/com/marklogic/client/datamovement/HostAvailabilityListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public HostAvailabilityListener withMinHosts(int numHosts) {
141141
*
142142
* @return this instance (for method chaining)
143143
*/
144-
public HostAvailabilityListener withHostUnavailableExceptions(Class<Throwable>... exceptionTypes) {
144+
@SafeVarargs
145+
public final HostAvailabilityListener withHostUnavailableExceptions(Class<Throwable>... exceptionTypes) {
145146
hostUnavailableExceptions = new ArrayList<>();
146147
for ( Class<Throwable> exception : exceptionTypes ) {
147148
hostUnavailableExceptions.add(exception);

0 commit comments

Comments
 (0)