This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit ae0d3a9c41aa6aa8a06485a413dec50259168c81 Author: ZenoYang <cookie...@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 fa051b983f..2a8d4cc015 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; @@ -88,8 +88,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 dc238bfcec..ccaaaf05ca 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-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org