Skip to content

Commit 3245c2a

Browse files
committed
MLE-23164 Addressed deprecation warnings in src/main/java
1 parent 75d5252 commit 3245c2a

File tree

26 files changed

+355
-430
lines changed

26 files changed

+355
-430
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ subprojects {
2020

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

2626
// To ensure that the Java Client continues to support Java 8, both source and target compatibility are set to 1.8.

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/JSONSplitter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ T getNextHandle() {
386386
switch (currentToken) {
387387
case FIELD_NAME:
388388
key.pop();
389-
key.push(jsonParser.getCurrentName());
389+
key.push(jsonParser.currentName());
390390
break;
391391

392392
case START_OBJECT:
@@ -557,7 +557,7 @@ public JsonToken nextToken() throws IOException {
557557
}
558558

559559
maintainDepth();
560-
return super.getCurrentToken();
560+
return super.currentToken();
561561
}
562562

563563
@Override

0 commit comments

Comments
 (0)