-
Notifications
You must be signed in to change notification settings - Fork 74
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
Conversation
There was a problem hiding this 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 withreplaceFirstChar { 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); |
There was a problem hiding this comment.
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.
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.
2380790
to
9500118
Compare
There was a problem hiding this 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.
794d34f
to
bd71653
Compare
There was a problem hiding this 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.
1c17da0
to
01ac909
Compare
01ac909
to
3ab00f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HOT
Addresses compiler warnings identified in the MarkLogic Java Client.
new Long(long).longValue()
withLong.parseLong(long)
orLong.valueOf(long).longValue()
for efficiency.StandardCharsets.UTF_8
instead of"UTF-8"
String literals.