Skip to content

feat: Java 21 modernization — retrieve - #5

Open
devin-ai-integration[bot] wants to merge 3 commits into
developfrom
devin/java21-retrieve
Open

feat: Java 21 modernization — retrieve#5
devin-ai-integration[bot] wants to merge 3 commits into
developfrom
devin/java21-retrieve

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 26, 2026

Copy link
Copy Markdown

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

Pattern Before After Delta
SAM anonymous classes 1 0 −1 (→ lambda)
Traditional instanceof 12 9 −3 (→ pattern matching)
Diamond operator candidates 2 0 −2 (→ <>)

Changes by file

BasicRetrievalService.java (3 modernizations):

  • ThreadFactory anonymous inner class → lambda expression (SAM conversion)
  • new PriorityBlockingQueue<Runnable>(…)new PriorityBlockingQueue<>(…) (diamond)
  • new ConcurrentLinkedQueue<RetrievalTask>()new ConcurrentLinkedQueue<>() (diamond)
  • e.getCause() instanceof SocketTimeoutException → pattern binding ste, eliminating redundant e.getCause() call
  • e.getCause() instanceof SSLHandshakeException → pattern binding sslEx, eliminating redundant e.getCause() calls

URLRetriever.java (1 modernization):

  • this.connection instanceof HttpsURLConnection + explicit cast → pattern binding httpsConn

Not converted (conservative rationale)

  • 9 remaining instanceof checks have no cast following in the same scope (negated checks, control-flow-only, or cast in a different method). Converting would add unused bindings.
  • DiscardPolicy anonymous subclass calls super.rejectedExecution(…) — cannot be a lambda.
  • No text blocks, switch expressions, records, or sealed class opportunities in this package.

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

  • Reduced boilerplate (lambda replaces 8-line anonymous class)
  • Eliminated redundant e.getCause() calls via pattern binding
  • Eliminated redundant type arguments via diamond operator
  • Verified: JAVA_HOME=jdk-21 ant -f release-build.xml passes (1 pre-existing deprecation warning in CachedDataRaster.java)
  • Public API diff: zero signature changes (only line-number shifts)

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 retrieve package).


Build verdict: ✅ PASS — JDK 21, ant -f release-build.xml
Public API diff: ✅ No changes
Session: https://app.devin.ai/sessions/81dc125070134ecba5aa7f0215c99a26
Flags for review: None

Requested by: @jakexcosme


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

devin-ai-integration Bot and others added 3 commits May 26, 2026 15:45
- 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 <[email protected]>
@devin-ai-integration

Copy link
Copy Markdown
Author
Original prompt from Jake

You are a child Devin session for COG-GTM/WorldWindJava Java 21 migration. Authorized to start. Work ONLY on package retrieve: src/gov/nasa/worldwind/retrieve/. Branch from origin/devin/java21-foundation into devin/java21-retrieve. Target PR base develop. Follow package workflow: pre-count SAM/instanceof, conservative Java 21 modernizations, no public API/test/unrelated changes, JDK21 ant -f release-build.xml, public API diff check, PR title "feat: Java 21 modernization — retrieve", body with before/after counts/rationale/session/verdict/flags. Return structured output.

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant