Skip to content

MLE-23004 - Addresses compiler warnings in the Java Client #1795

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 22, 2025

Conversation

BillFarber
Copy link
Contributor

Addresses compiler warnings identified in the MarkLogic Java Client.

  • Replaces new Long(long).longValue() with Long.parseLong(long) or Long.valueOf(long).longValue() for efficiency.
  • Uses StandardCharsets.UTF_8 instead of "UTF-8" String literals.
  • Removes unused variables and unnecessary checks.

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 compiler warnings in the MarkLogic Java Client by modernizing deprecated API usage and improving code quality. The changes focus on replacing deprecated methods with their modern equivalents and removing unnecessary code constructs.

  • Replaces deprecated capitalize() method with replaceFirstChar { it.uppercase() } in Kotlin code
  • Updates primitive wrapper instantiation patterns (new Integer(), new Long()) with modern alternatives
  • Replaces string literals for character encodings with StandardCharsets.UTF_8
  • Modernizes Gradle task registration and improves iterator usage patterns

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Generator.kt Updates deprecated capitalize() calls and toUpperCase() to modern Kotlin string methods
ToolsPlugin.kt Replaces deprecated tasks.create() with tasks.register() for lazy task creation
SSLTest.java Removes unnecessary new Integer() wrapper instantiation and improves code formatting
HandleAsTest.java Replaces UTF-8 string literals with StandardCharsets.UTF_8 and improves code formatting
BasicPage.java Updates new Long() constructor usage to Long.valueOf() and improves formatting
TypedRow.java Replaces inefficient new Long().longValue() pattern with Long.parseLong()

@@ -20,7 +20,7 @@ public String getUri() {
}

public long getRowNum() {
return new Long(rowNum).longValue();
return Long.parseLong(rowNum);
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

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

Using Long.parseLong(rowNum) assumes rowNum is a String, but this could cause a NumberFormatException if rowNum contains invalid numeric data. The original code using new Long(rowNum).longValue() suggests rowNum might be a long primitive. If rowNum is already a long, this should be just 'return rowNum;' or if it's a String that represents a long value, consider using Long.valueOf(rowNum) for consistency with the caching behavior used elsewhere in the PR.

Suggested change
return Long.parseLong(rowNum);
try {
return Long.valueOf(rowNum).longValue();
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid rowNum value: " + rowNum, e);
}

Copilot uses AI. Check for mistakes.

@BillFarber BillFarber force-pushed the task/cleanWarnings branch from 2380790 to 9500118 Compare July 22, 2025 00:18
Copy link
Contributor

@rjrudin rjrudin left a comment

Choose a reason for hiding this comment

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

Can you resubmit this without the formatting changes? Unfortunately most Java Client source files aren't formatted based on .editorconfig. That's a separate effort, have this PR contain the compilation warning fixes.

@BillFarber BillFarber force-pushed the task/cleanWarnings branch 2 times, most recently from 794d34f to bd71653 Compare July 22, 2025 14:59
@BillFarber BillFarber requested a review from rjrudin July 22, 2025 14:59
Copy link
Contributor

@rjrudin rjrudin left a comment

Choose a reason for hiding this comment

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

All looks good, except still have whitespace changes in BasicPage and SSLTest. I just want to avoid those so that the "git blame" shows the real last author of each line, which is useful for quickly debugging some of these older files.

@BillFarber BillFarber force-pushed the task/cleanWarnings branch 2 times, most recently from 1c17da0 to 01ac909 Compare July 22, 2025 15:38
@BillFarber BillFarber force-pushed the task/cleanWarnings branch from 01ac909 to 3ab00f4 Compare July 22, 2025 15:43
@BillFarber BillFarber requested a review from rjrudin July 22, 2025 15:44
Copy link
Contributor

@rjrudin rjrudin left a comment

Choose a reason for hiding this comment

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

HOT

@BillFarber BillFarber merged commit 368454e into marklogic:develop Jul 22, 2025
1 of 2 checks passed
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