mirror of https://github.com/apache/druid.git
Merge pull request #908 from metamx/fix-smile-0.7
(port from 0.6.x) fix smile exception on error + content-type
This commit is contained in:
commit
46dfce6905
|
@ -126,6 +126,7 @@ public class QueryResource
|
|||
String queryId = null;
|
||||
|
||||
final boolean isSmile = APPLICATION_SMILE.equals(req.getContentType());
|
||||
final String contentType = isSmile ? APPLICATION_SMILE : APPLICATION_JSON;
|
||||
|
||||
ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper;
|
||||
final ObjectWriter jsonWriter = req.getParameter("pretty") == null
|
||||
|
@ -209,7 +210,7 @@ public class QueryResource
|
|||
outputStream.close();
|
||||
}
|
||||
},
|
||||
isSmile ? APPLICATION_SMILE : APPLICATION_JSON
|
||||
contentType
|
||||
)
|
||||
.header("X-Druid-Query-Id", queryId)
|
||||
.header("X-Druid-Response-Context", jsonMapper.writeValueAsString(responseContext))
|
||||
|
@ -249,10 +250,10 @@ public class QueryResource
|
|||
catch (Exception e2) {
|
||||
log.error(e2, "Unable to log query [%s]!", query);
|
||||
}
|
||||
return Response.serverError().entity(
|
||||
jsonWriter.writeValueAsString(
|
||||
return Response.serverError().type(contentType).entity(
|
||||
jsonWriter.writeValueAsBytes(
|
||||
ImmutableMap.of(
|
||||
"error", e.getMessage()
|
||||
"error", e.getMessage() == null ? "null exception" : e.getMessage()
|
||||
)
|
||||
)
|
||||
).build();
|
||||
|
@ -285,8 +286,8 @@ public class QueryResource
|
|||
.addData("peer", req.getRemoteAddr())
|
||||
.emit();
|
||||
|
||||
return Response.serverError().entity(
|
||||
jsonWriter.writeValueAsString(
|
||||
return Response.serverError().type(contentType).entity(
|
||||
jsonWriter.writeValueAsBytes(
|
||||
ImmutableMap.of(
|
||||
"error", e.getMessage() == null ? "null exception" : e.getMessage()
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue