From 43041ed4ba3796316ea55917645a334c2b56df89 Mon Sep 17 00:00:00 2001 From: Charles Allen Date: Mon, 8 Dec 2014 13:09:48 -0800 Subject: [PATCH] Added checks for backwards compat on MediaTypes --- .../java/io/druid/server/AsyncQueryForwardingServlet.java | 4 +++- server/src/main/java/io/druid/server/QueryResource.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java b/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java index ce477f63829..a04feb46307 100644 --- a/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java +++ b/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java @@ -59,6 +59,8 @@ import java.util.concurrent.TimeUnit; public class AsyncQueryForwardingServlet extends AsyncProxyServlet { private static final EmittingLogger log = new EmittingLogger(AsyncQueryForwardingServlet.class); + @Deprecated // use SmileMediaTypes.APPLICATION_JACKSON_SMILE + private static final String APPLICATION_SMILE = "application/smile"; private static void handleException(HttpServletResponse response, ObjectMapper objectMapper, Exception exception) throws IOException @@ -103,7 +105,7 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(request.getContentType()); + final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(request.getContentType()) || APPLICATION_SMILE.equals(request.getContentType()); final ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper; String host = hostFinder.getDefaultHost(); diff --git a/server/src/main/java/io/druid/server/QueryResource.java b/server/src/main/java/io/druid/server/QueryResource.java index bb8de0fffdb..82af76f8d43 100644 --- a/server/src/main/java/io/druid/server/QueryResource.java +++ b/server/src/main/java/io/druid/server/QueryResource.java @@ -49,6 +49,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.DELETE; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -69,6 +70,8 @@ import java.util.UUID; public class QueryResource { private static final EmittingLogger log = new EmittingLogger(QueryResource.class); + @Deprecated // use SmileMediaTypes.APPLICATION_JACKSON_SMILE + private static final String APPLICATION_SMILE = "application/smile"; private final ServerConfig config; private final ObjectMapper jsonMapper; @@ -104,7 +107,7 @@ public class QueryResource @DELETE @Path("{id}") - @Produces("application/json") + @Produces(MediaType.APPLICATION_JSON) public Response getServer(@PathParam("id") String queryId) { queryManager.cancelQuery(queryId); @@ -123,7 +126,7 @@ public class QueryResource byte[] requestQuery = null; String queryId = null; - final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(req.getContentType()); + final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(req.getContentType()) || APPLICATION_SMILE.equals(req.getContentType()); final String contentType = isSmile ? SmileMediaTypes.APPLICATION_JACKSON_SMILE : MediaType.APPLICATION_JSON; ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper;