← Back to Pull requests

refactor: replace deprecated URL constructors in production code #20688

Closed
unknown closed this pull request without merging on Oct 23, 2026 06:25 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 11:15 UTC
Author

Part of #20525.

Description

This is the first cleanup from the table in #20525. It replaces the deprecated java.net.URL constructors in production code with URI.create(...).toURL() or new URI(...).toURL(). Test code still uses the old constructors, so I didn't add the forbidden-apis rule here. I plan to clean up the tests and add the rule in a follow-up PR.

I tried to keep behaviour the same:

  • Where the old code turned MalformedURLException into a specific exception (ISE in HttpPostEmitter, ParseException in FileBasedProtobufBytesDecoder, IAE in HttpServerInventoryView), the catch now also covers IllegalArgumentException or URISyntaxException, so callers see the same exception type.

  • For pre-encoded paths (TaskLocation, ServiceLocation, LookupCoordinatorManager) I build the URI from a string with Guava HostAndPort rather than the multi-arg URI constructors, which would encode the path a second time. HostAndPort also keeps IPv6 hosts in brackets like the old URL constructor did, and the port is left out when it isn't set.

  • Relative forms (HttpLoadQueuePeon, ChangeRequestHttpSyncer) now use URI.resolve. I checked it gives the same result as the old new URL(base, spec) for bases with no path, a trailing slash, or one path segment.

  • URI is stricter than URL, so malformed input such as unencoded spaces is now rejected earlier.
  • I built the touched modules and ran the unit tests for the changed classes. They pass, except DirectDruidClientTest and FileBasedProtobufBytesDecoderTest.testDescriptorUrl on my Windows machine: the first fails in setup on temp file locking, and the second builds a file URL from a Windows path with backslashes, which URI rejects. Both should be fine on Linux CI.

    Release note


    No release note, there's no user-facing change.

    <hr>

    ##### Key changed/added classes in this PR
    TaskLocation
    ServiceLocation
    HttpPostEmitter
    ChannelResourceFactory
    DirectDruidClient
    HttpServerInventoryView
    HttpLoadQueuePeon
    ChangeRequestHttpSyncer
    LookupCoordinatorManager
    BuildInfo
    CoordinatorRedirectInfo
    OverlordRedirectInfo
    SystemServerPropertiesTable
    PrometheusEmitter
    CommonCacheNotifier
    RestUpdateSender
    * FileBasedProtobufBytesDecoder

    <hr>

    This PR has:

  • been self-reviewed.

  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

  • a behaviour-preserving refactor covered by the existing unit tests of the changed classes.
  • Diff: 312 lines (+234 / -78) across 3 files Reviewer: akshat-lakhera Review duration: 1150m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 312 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.344
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20688"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.3% (MEDIUM) · Higher = larger blast radius
    40.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.9% · Safe to merge
    15.9%
    Repository