imply-cheddar commented on code in PR #13564:
URL: https://github.com/apache/druid/pull/13564#discussion_r1049318622


##########
server/src/main/java/org/apache/druid/server/QueryResource.java:
##########
@@ -171,161 +167,112 @@ public Response cancelQuery(@PathParam("id") String 
queryId, @Context final Http
   @POST
   @Produces({MediaType.APPLICATION_JSON, 
SmileMediaTypes.APPLICATION_JACKSON_SMILE})
   @Consumes({MediaType.APPLICATION_JSON, 
SmileMediaTypes.APPLICATION_JACKSON_SMILE, APPLICATION_SMILE})
+  @Nullable
   public Response doPost(
       final InputStream in,
       @QueryParam("pretty") final String pretty,
-
-      // used to get request content-type,Accept header, remote address and 
auth-related headers
       @Context final HttpServletRequest req
   ) throws IOException
   {
     final QueryLifecycle queryLifecycle = queryLifecycleFactory.factorize();
 
-    final ResourceIOReaderWriter ioReaderWriter = 
createResourceIOReaderWriter(req, pretty != null);
+    final ResourceIOReaderWriter io = createResourceIOReaderWriter(req, pretty 
!= null);
 
     final String currThreadName = Thread.currentThread().getName();
     try {
-      final Query<?> query = readQuery(req, in, ioReaderWriter);
+      final Query<?> query;
+      try {
+        query = readQuery(req, in, io);
+      }
+      catch (QueryException e) {
+        return 
io.getResponseWriter().buildNonOkResponse(e.getFailType().getExpectedStatus(), 
e);
+      }
+
       queryLifecycle.initialize(query);
-      final String queryId = queryLifecycle.getQueryId();
       final String queryThreadName = queryLifecycle.threadName(currThreadName);
       Thread.currentThread().setName(queryThreadName);
 
       if (log.isDebugEnabled()) {
         log.debug("Got query [%s]", queryLifecycle.getQuery());
       }
 
-      final Access authResult = queryLifecycle.authorize(req);
+      final Access authResult;
+      try {
+        authResult = queryLifecycle.authorize(req);
+      }
+      catch (RuntimeException e) {
+        return io.getResponseWriter()
+                 .buildNonOkResponse(
+                     HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+                     QueryInterruptedException.wrapIfNeeded(e)

Review Comment:
   Yeah... when we clean up everything and just make them all QueryException, 
we can delete it entirely and not have the misnomer ;)



-- 
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]

Reply via email to