FrankChen021 commented on code in PR #20152:
URL: https://github.com/apache/druid/pull/20152#discussion_r3914083334
##########
server/src/main/java/org/apache/druid/client/DirectDruidClient.java:
##########
@@ -243,6 +244,71 @@ public ClientResponse<InputStream>
handleResponse(HttpResponse response, Traffic
{
trafficCopRef.set(trafficCop);
checkQueryTimeout();
+ // Handle 429/503 HTML before JSON parse to avoid JsonParseException
0x3c ('<')
+ final int statusCode = response.getStatus().getCode();
+ final String contentType =
response.headers().get(HttpHeaders.Names.CONTENT_TYPE);
+ final ChannelBuffer contentBuffer = response.getContent();
+ boolean isHtmlContentType = contentType != null &&
StringUtils.toLowerCase(contentType).contains("text/html");
+ boolean isHtmlBody = false;
+ if (contentBuffer.readableBytes() > 0) {
Review Comment:
[P2] Chunked HTML responses can bypass classification
When a chunked response has an empty initial buffer, this check leaves
isHtmlBody false. Subsequent handleChunk calls only enqueue bytes and do not
retain or inspect the response prefix, so a later chunk beginning with HTML is
fed to JsonParserIterator and becomes a generic JSON parse/interruption error.
Persist the classification across chunks or buffer the prefix before
enqueueing, and add an empty-initial-chunk test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]