diff --git a/server/src/main/java/io/druid/client/DirectDruidClient.java b/server/src/main/java/io/druid/client/DirectDruidClient.java index c354bc18259..2143f31f41a 100644 --- a/server/src/main/java/io/druid/client/DirectDruidClient.java +++ b/server/src/main/java/io/druid/client/DirectDruidClient.java @@ -159,15 +159,20 @@ public class DirectDruidClient implements QueryRunner byteCount += response.getContent().readableBytes(); try { - final Map responseContext = objectMapper.readValue( - response.headers().get("X-Druid-Response-Context"), new TypeReference>() - { - } - ); - context.putAll(responseContext); + final String responseContext = response.headers().get("X-Druid-Response-Context"); + // context may be null in case of error or query timeout + if (responseContext != null) { + context.putAll( + objectMapper.>readValue( + responseContext, new TypeReference>() + { + } + ) + ); + } } catch (IOException e) { - e.printStackTrace(); + log.error(e, "Unable to parse response context from url[%s]", url); } return super.handleResponse(response);