← Back to Pull requests

fix!: fix CI and JDK HttpClient failures on JDK 25.0.5 caused by query response trailers #20717

Closed
unknown closed this pull request without merging on Oct 24, 2026 07:38 UTC
View on GitHub
unknown unknown commented on Oct 24, 2026 05:31 UTC
Author

Description

Since #16672, Brokers and Historicals always declare Trailer: X-Druid-Response-Complete and send that trailer after the last chunk of every streamed /druid/v2 and /druid/v2/sql response.

JDK-8383439 ("Enhance HTTP Client Response Handling", October 2026 CPU) shipped in JDK 17.0.21, 21.0.13 and 25.0.5. It makes java.net.http.HttpClient require CRLF right after the last chunk (new ChunkedBodyParser.tryConsumeCRLF). A trailer section now fails the response with java.net.ProtocolException: CR expected. Older JDKs skipped those 2 bytes without checking them. So on current JDKs, any java.net.http client that queries a Broker or Historical directly fails at the end of the response. That includes the Druid JDBC driver (DruidHttpClientImpl) and ResponseIdentityHeaderTest, which now fails deterministically on CI since setup-java picked up Zulu 25.0.5. RFC 9112 §7.1 includes the trailer section in the chunked body grammar, so this looks like a JDK regression. I found no public OpenJDK report; JDK-8383439 itself is not public.

Fix

QueryResultPusher now declares and sends trailers only when the request has TE: trailers, which is how RFC 9110 §10.1.4 has a client say it accepts trailers. Without that header, responses are unchanged apart from the missing Trailer header and trailer section.

No Druid code reads X-Druid-Response-Complete or X-Error-Message (DirectDruidClient doesn't). The Router drops trailers anyway, because Jetty's proxy treats TE and Trailer as hop-by-hop headers (AbstractProxyServlet.HOP_HEADERS). So Broker→Historical and Router traffic behaves the same as before.

Evidence

  • CI on Zulu 25.0.5 fails. This job resolved Zulu 25.0.5+8 (2026-10-24 03:25 UTC). In ResponseIdentityHeaderTest, the three query tests (Broker native, Broker SQL, Historical native) fail with java.net.ProtocolException: CR expected; the four GET tests pass.

  • Unrelated PRs fail the same way. For example, #20710 (a dependabot OpenTelemetry bump) fails only unit tests (25, R,B,P), on Zulu 25.0.5+8, with the same three ResponseIdentityHeaderTest errors.

  • CI on Zulu 25.0.4 passes. This master job resolved Zulu 25.0.4+1.1 (01:49 UTC the same day) and ResponseIdentityHeaderTest passed 7/7. Master is green only because nothing has merged since setup-java switched to 25.0.5. It will also start failing on the 17 and 21 jobs once they resolve 17.0.21 and 21.0.13.

  • Wire format. A raw-socket capture of a Broker /druid/v2/sql response ends with 0\r\nX-Druid-Response-Complete: true\r\n\r\n.

  • JDK change. JDK-8383439 was committed on 2026-10-16 to jdk17u, jdk21u and jdk25u. The first GA tags that contain it are jdk-17.0.21-ga, jdk-21.0.13-ga and jdk-25.0.5-ga.
  • Release note

    Brokers and Historicals now send the X-Druid-Response-Complete and X-Error-Message HTTP trailers only when the request includes the TE: trailers header. Clients that read these trailers must send that header. This fixes query failures (java.net.ProtocolException: CR expected) in java.net.http.HttpClient-based clients, including the Druid JDBC driver, on JDK 17.0.21, 21.0.13 and 25.0.5.

    <hr>

    ##### Key changed/added classes in this PR
    QueryResultPusher
    * QueryResponseTrailerTest (new embedded test: raw-socket wire check with and without TE: trailers, plus HttpClient reads from Broker and Historical)

    <hr>

    This PR has:

  • been self-reviewed.

  • added unit tests or modified existing tests to cover new code paths.

  • added integration tests.
  • Diff: 567 lines (+425 / -142) across 7 files Reviewer: gianm Review duration: 126m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 567 lines diff across 7 files
    0.50
    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%
    56%
    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.379
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20717"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 21.5% · Safe to merge
    21.5%
    Repository