You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/24 00:49:51 UTC

[doris] branch master updated: [Fix](HttpServer) Chinese garbled characters appear when obtaining query plan (#18820)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d2f50ce3f5 [Fix](HttpServer) Chinese garbled characters appear when obtaining query plan (#18820)
d2f50ce3f5 is described below

commit d2f50ce3f5ec831b5a961c5b737bb392ca2ab1b9
Author: ZenoYang <co...@qq.com>
AuthorDate: Mon Apr 24 08:49:44 2023 +0800

    [Fix](HttpServer) Chinese garbled characters appear when obtaining query plan (#18820)
    
    When obtaining the query plan, the Chinese garbled characters in the predicate lead to incorrect data results.
---
 .../doris/httpv2/rest/TableQueryPlanAction.java    |  4 +--
 .../doris/httpv2/rest/manager/HttpUtils.java       |  7 ++++
 .../org/apache/doris/httpv2/util/HttpUtil.java     | 39 ----------------------
 3 files changed, 9 insertions(+), 41 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
index c94a92beb8..033a03fa0b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
@@ -28,7 +28,7 @@ import org.apache.doris.catalog.Table;
 import org.apache.doris.common.DorisHttpException;
 import org.apache.doris.common.MetaNotFoundException;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.httpv2.util.HttpUtil;
+import org.apache.doris.httpv2.rest.manager.HttpUtils;
 import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.planner.PlanFragment;
 import org.apache.doris.planner.Planner;
@@ -92,8 +92,8 @@ public class TableQueryPlanAction extends RestBaseController {
         // just allocate 2 slot for top holder map
         Map<String, Object> resultMap = new HashMap<>(4);
 
-        String postContent = HttpUtil.getBody(request);
         try {
+            String postContent = HttpUtils.getBody(request);
             // may be these common validate logic should be moved to one base class
             if (Strings.isNullOrEmpty(postContent)) {
                 return ResponseEntityBuilder.badRequest("POST body must contains [sql] root object");
diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/HttpUtils.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/HttpUtils.java
index b2bda47bd6..7eecc725ba 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/HttpUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/HttpUtils.java
@@ -25,6 +25,7 @@ import org.apache.doris.persist.gson.GsonUtils;
 import org.apache.doris.system.Frontend;
 
 import com.google.gson.reflect.TypeToken;
+import org.apache.commons.io.IOUtils;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
@@ -36,10 +37,12 @@ import org.apache.http.util.EntityUtils;
 import org.apache.parquet.Strings;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
+import javax.servlet.http.HttpServletRequest;
 
 /*
  * used to forward http requests from manager to be.
@@ -116,4 +119,8 @@ public class HttpUtils {
         }
         return GsonUtils.GSON.toJson(responseEntity.getData());
     }
+
+    public static String getBody(HttpServletRequest request) throws IOException {
+        return IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/util/HttpUtil.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/util/HttpUtil.java
deleted file mode 100644
index a2e0c91063..0000000000
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/util/HttpUtil.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.httpv2.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-
-public class HttpUtil {
-    public static String getBody(HttpServletRequest request) {
-        StringBuilder data = new StringBuilder();
-        String line = null;
-        BufferedReader reader = null;
-        try {
-            reader = request.getReader();
-            while (null != (line = reader.readLine())) {
-                data.append(new String(line.getBytes("utf-8")));
-            }
-        } catch (IOException e) {
-            // CHECKSTYLE IGNORE THIS LINE
-        }
-        return data.toString();
-    }
-}


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