Replace deprecated third-party and JDK API calls with modern equivalents#18363
Conversation
a2ce815 to
31482a7
Compare
49c895a to
8e5cff4
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #18363 +/- ##
============================================
- Coverage 63.45% 63.44% -0.02%
Complexity 1683 1683
============================================
Files 3253 3253
Lines 198884 198897 +13
Branches 30798 30798
============================================
- Hits 126196 126181 -15
- Misses 62620 62644 +24
- Partials 10068 10072 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
overall lgtm. |
Thanks @xiangfu0 . There doesn't seem to be a checkstyle hook to prevent that, but I had added a lint step in the precommit skill in this PR: #18361 |
|
Added 4 checkstyle rules to
These 4 have zero false positives — the deprecated and non-deprecated APIs have distinct names, so the regex matches are precise. The remaining deprecated APIs we cleaned up ( |
1372a46 to
ddfbe98
Compare
First round of deprecation cleanup, targeting mechanical, low-risk replacements of deprecated third-party and JDK APIs. Each replacement was identified by compiling with -Xlint:deprecation, reading the @deprecated Javadoc in the library source, and verifying the replacement compiles and preserves existing behavior. Replacements: - ObjectNode.put(String, JsonNode) → .set(String, JsonNode) - JsonNode.fields() → .properties() - Class.newInstance() → getDeclaredConstructor().newInstance() - FileUtils.readFileToString/write — add Charset parameter - IOUtils.toString/write — add Charset parameter - Guava Files.createTempDir() → JDK Files.createTempDirectory() - StringUtils.remove/replace/compare → Strings.CS equivalents - RandomStringUtils.random*() → secure().next*() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ddfbe98 to
a9e4c3b
Compare
Summary
First round of deprecation cleanup, targeting mechanical, low-risk replacements of deprecated third-party and JDK APIs. Follow-up PRs will address the remaining warnings that require more involved changes (internal Pinot API migrations, larger refactors, etc.).
Each deprecated API and its replacement was identified by:
-Xlint:deprecationto find all deprecation warnings@deprecatedJavadoc on each method in the library source to find the documented replacementReplacements
ObjectNode.put(String, JsonNode).set(String, JsonNode)JsonNode.fields().properties()Class.newInstance()getDeclaredConstructor().newInstance()FileUtils.readFileToString(File)readFileToString(File, Charset)FileUtils.write(File, CharSequence)write(File, CharSequence, Charset)IOUtils.toString(InputStream)toString(InputStream, Charset)IOUtils.write(String, OutputStream)write(String, OutputStream, Charset)Files.createTempDir()(Guava)java.nio.file.Files.createTempDirectory()StringUtils.remove(String, String)Strings.CS.remove(String, String)StringUtils.replace(String, String, String)Strings.CS.replace(String, String, String)StringUtils.compare(String, String)Strings.CS.compare(String, String)RandomStringUtils.random*()RandomStringUtils.secure().next*()secure()since the deprecated statics delegate tosecure().Note:
StringUtils.remove(String, char)is NOT deprecated — only the(String, String)overload is. Those calls were left unchanged.Test plan
spotless:apply— all affected modules formattedcheckstyle:check— zero violations across all affected moduleslicense:check— all headers validtest-compile— compiles cleanly with zero new deprecation warnings for the replaced APIs🤖 Generated with Claude Code