feat: Java 21 modernization — retrieve - #5
Conversation
- Convert ThreadFactory anonymous class to lambda (SAM) in BasicRetrievalService - Apply pattern matching instanceof in BasicRetrievalService (SocketTimeoutException, SSLHandshakeException) - Apply pattern matching instanceof in URLRetriever (HttpsURLConnection) - Use diamond operator for PriorityBlockingQueue and ConcurrentLinkedQueue in BasicRetrievalService - No public API changes, no test changes Co-Authored-By: Jake Cosme <jake@cognition.ai>
Original prompt from Jake
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Description of the Change
Conservative Java 21 modernization of the
src/gov/nasa/worldwind/retrieve/package. Changes are limited to internal implementation — no public API, test, or unrelated changes.Before → After Counts
instanceof<>)Changes by file
BasicRetrievalService.java (3 modernizations):
ThreadFactoryanonymous inner class → lambda expression (SAM conversion)new PriorityBlockingQueue<Runnable>(…)→new PriorityBlockingQueue<>(…)(diamond)new ConcurrentLinkedQueue<RetrievalTask>()→new ConcurrentLinkedQueue<>()(diamond)e.getCause() instanceof SocketTimeoutException→ pattern bindingste, eliminating redundante.getCause()calle.getCause() instanceof SSLHandshakeException→ pattern bindingsslEx, eliminating redundante.getCause()callsURLRetriever.java (1 modernization):
this.connection instanceof HttpsURLConnection+ explicit cast → pattern bindinghttpsConnNot converted (conservative rationale)
instanceofchecks have no cast following in the same scope (negated checks, control-flow-only, or cast in a different method). Converting would add unused bindings.DiscardPolicyanonymous subclass callssuper.rejectedExecution(…)— cannot be a lambda.Why Should This Be In Core?
Keeps the codebase aligned with the Java 21 LTS target established in the foundation branch. These are mechanical, risk-free idiom upgrades to internal implementation.
Benefits
e.getCause()calls via pattern bindingJAVA_HOME=jdk-21 ant -f release-build.xmlpasses (1 pre-existing deprecation warning in CachedDataRaster.java)Potential Drawbacks
None. All changes are internal implementation details with identical runtime behavior.
Applicable Issues
Part of the Java 21 migration effort (child session for
retrievepackage).Build verdict: ✅ PASS — JDK 21,
ant -f release-build.xmlPublic API diff: ✅ No changes
Session: https://app.devin.ai/sessions/81dc125070134ecba5aa7f0215c99a26
Flags for review: None
Requested by: @jakexcosme
Devin Review