This is an automated email from the ASF dual-hosted git repository.

lichaoyong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f1d25a  [Bug] Set the HttpResponseStatus for QueryProfile when 
query_id been not set (#3710)
5f1d25a is described below

commit 5f1d25a31a81d708974e72e6d698044cab4580cb
Author: lichaoyong <lichaoyong...@gmail.com>
AuthorDate: Fri May 29 10:06:43 2020 +0800

    [Bug] Set the HttpResponseStatus for QueryProfile when query_id been not 
set (#3710)
    
    Doris can get query profile by HttpRequest
    ```
    http://fe_host:web_port/query_profile?query_id=123456
    ```
    Now, if query_id is not found, the 404 error is not set in HttpHeader.
---
 .../org/apache/doris/common/util/ProfileManager.java    |  2 +-
 .../apache/doris/http/action/QueryProfileAction.java    | 17 +++++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/fe/src/main/java/org/apache/doris/common/util/ProfileManager.java 
b/fe/src/main/java/org/apache/doris/common/util/ProfileManager.java
index 9c641dc..1705bb6 100644
--- a/fe/src/main/java/org/apache/doris/common/util/ProfileManager.java
+++ b/fe/src/main/java/org/apache/doris/common/util/ProfileManager.java
@@ -155,7 +155,7 @@ public class ProfileManager {
         try {
             ProfileElement element = profileMap.get(queryID);
             if (element == null) {
-                return new String("query id " + queryID + " not found." );
+                return null;
             }
             
             return element.profileContent;
diff --git 
a/fe/src/main/java/org/apache/doris/http/action/QueryProfileAction.java 
b/fe/src/main/java/org/apache/doris/http/action/QueryProfileAction.java
index 77db97d..69ac168 100644
--- a/fe/src/main/java/org/apache/doris/http/action/QueryProfileAction.java
+++ b/fe/src/main/java/org/apache/doris/http/action/QueryProfileAction.java
@@ -26,6 +26,7 @@ import org.apache.doris.http.IllegalArgException;
 import com.google.common.base.Strings;
 
 import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpResponseStatus;
 
 public class QueryProfileAction extends WebBaseAction {
 
@@ -47,14 +48,18 @@ public class QueryProfileAction extends WebBaseAction {
         }
         
         String queryProfileStr = 
ProfileManager.getInstance().getProfile(queryId);
-        appendQueryPrifile(response.getContent(), queryProfileStr);
-        
-        getPageFooter(response.getContent());
-        
-        writeResponse(request, response);
+        if (queryProfileStr != null) {
+            appendQueryProfile(response.getContent(), queryProfileStr);
+            getPageFooter(response.getContent());
+            writeResponse(request, response);
+        } else {
+            appendQueryProfile(response.getContent(), "query id " + queryId + 
" not found.");
+            getPageFooter(response.getContent());
+            writeResponse(request, response, HttpResponseStatus.NOT_FOUND);
+        }
     }
     
-    private void appendQueryPrifile(StringBuilder buffer, String 
queryProfileStr) {
+    private void appendQueryProfile(StringBuilder buffer, String 
queryProfileStr) {
         buffer.append("<pre>");
         buffer.append(queryProfileStr);
         buffer.append("</pre>");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to