Skip to content

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

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 1 commit into from
Jul 24, 2025

Conversation

rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Jul 24, 2025

Copilot got a little carried away and knocked out some issues in src/test/java too. More to come after this PR.

Addresses unchecked and deprecation warnings by:

  • Adding compiler arguments to include deprecation details.
  • Removing unnecessary finalize() methods.
  • Replacing raw types with parameterized types in test classes.
  • Replacing StringBuffer with StringBuilder.
  • Using isEmpty() instead of checking length > 0.
  • Replacing Boolean constructor with boolean literal.
  • Various other minor code improvements.

@Copilot Copilot AI review requested due to automatic review settings July 24, 2025 19:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses compilation warnings across the MarkLogic Java Client API codebase by fixing unchecked operations, deprecation warnings, and other code quality issues. The changes improve type safety and modernize the codebase to reduce compiler warnings.

Key changes include:

  • Added generic type parameters to collections and removed raw type usage
  • Replaced deprecated API calls with modern alternatives
  • Added @SuppressWarnings annotations where necessary for unavoidable warnings
  • Updated method calls to use current non-deprecated versions

Reviewed Changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
IOTestUtil.java Added @SafeVarargs annotation and removed unused method
XMLSplitterTest.java Added generic types to XMLSplitter instances and fixed File constructor
QueryBatcherTest.java Added generic types to Set declaration
JacksonCSVSplitterTest.java Updated deprecated fields() call to properties()
JSONSplitterTest.java Added generic types to JSONSplitter instances
ApplyTransformTest.java Added generic type to List declaration
PlanExpressionTest.java Fixed array parameter usage
JacksonStreamTest.java Updated deprecated getCurrentName() calls and removed unused import
JacksonHandleTest.java Replaced deprecated put() calls with set()
BulkReadWriteTest.java Added proper charset encoding and exception handling
DatabaseClientPropertySourceTest.java Simplified HashMap initialization
Multiple test files Added @SuppressWarnings annotations and updated deprecated method calls

// test with 1 arg
String contents;
try {
contents = URLEncoder.encode(uri, "UTF-8").replaceFirst(".*", regex);
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using StandardCharsets.UTF_8 instead of the hardcoded "UTF-8" string to avoid potential typos and improve code maintainability.

Suggested change
contents = URLEncoder.encode(uri, "UTF-8").replaceFirst(".*", regex);
contents = URLEncoder.encode(uri, StandardCharsets.UTF_8.name()).replaceFirst(".*", regex);

Copilot uses AI. Check for mistakes.

@@ -1402,7 +1433,7 @@ public JsonNode expectedJSONDocument(String filename) throws JsonParseException,
// get json document for expected result
ObjectMapper mapper = new ObjectMapper();
JsonFactory jfactory = new JsonFactory();
JsonParser jParser = jfactory.createJsonParser(new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename));
JsonParser jParser = jfactory.createParser(new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename));
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using Path.of() or Paths.get() with proper path separators instead of string concatenation for file paths to improve cross-platform compatibility.

Suggested change
JsonParser jParser = jfactory.createParser(new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename));
JsonParser jParser = jfactory.createParser(new File(Path.of("src", "test", "java", "com", "marklogic", "client", "functionaltest", "data", filename).toString()));

Copilot uses AI. Check for mistakes.

Some of these have SuppressWarnings at the class level because they have so much unchecked warnings. Many of those are due to rampant copy/paste of duplicated code.
@rjrudin rjrudin force-pushed the feature/23146-compile-fixes branch from ae13e3b to b73461f Compare July 24, 2025 19:23
@rjrudin rjrudin merged commit 14128e4 into develop Jul 24, 2025
2 checks passed
@rjrudin rjrudin deleted the feature/23146-compile-fixes branch July 24, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants