You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "liucongjy (via GitHub)" <gi...@apache.org> on 2025/07/19 13:03:09 UTC

[PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

liucongjy opened a new pull request, #9594:
URL: https://github.com/apache/seatunnel/pull/9594

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   
   This pull request resolves the issue of garbled text display for collection task logs in the seatunel engine-service interface
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
   -->
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2239891809


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse("html");
+        testLogRestApiResponse("JSON");
+    }
+
+    public void testLogRestApiResponse(String format) throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL("http://localhost:" + HTTP_PORT + "/logs?format=" + format);
+            conn = (HttpURLConnection) url.openConnection();
+
+            Assertions.assertEquals(200, conn.getResponseCode());
+
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+            String response = in.lines().collect(Collectors.joining("\r\n"));

Review Comment:
   The `response` seem like useless?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2218125257


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/BaseServlet.java:
##########
@@ -46,47 +46,55 @@ public BaseServlet(NodeEngineImpl nodeEngine) {
     }
 
     protected void writeJson(HttpServletResponse resp, Object obj) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.getWriter().write(new Gson().toJson(obj));
     }
 
     protected void writeJson(HttpServletResponse resp, JsonArray jsonArray) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.getWriter().write(jsonArray.toString());
     }
 
     protected void writeJson(HttpServletResponse resp, JsonObject jsonObject) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.getWriter().write(jsonObject.toString());
     }
 
     protected void writeJson(HttpServletResponse resp, JsonArray jsonArray, int statusCode)
             throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.setStatus(statusCode);
         resp.getWriter().write(jsonArray.toString());
     }
 
     protected void writeJson(HttpServletResponse resp, JsonObject jsonObject, int statusCode)
             throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.setStatus(statusCode);
         resp.getWriter().write(jsonObject.toString());
     }
 
     protected void writeJson(HttpServletResponse resp, Object obj, int statusCode)
             throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.setStatus(statusCode);
         resp.getWriter().write(new Gson().toJson(obj));
     }
 
     protected void write(HttpServletResponse resp, Object obj) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("text/plain");
         resp.getWriter().write(obj.toString());
     }
 
     protected void writeHtml(HttpServletResponse resp, Object obj) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("text/html; charset=UTF-8");

Review Comment:
   The charset specification is redundant in this content type since UTF-8 encoding is already set via setCharacterEncoding(). Consider using just "text/html" for consistency with other methods, or remove the setCharacterEncoding() call and rely on the charset in the content type.
   ```suggestion
           resp.setContentType("text/html");
   ```



##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/BaseServlet.java:
##########
@@ -46,47 +46,55 @@ public BaseServlet(NodeEngineImpl nodeEngine) {
     }
 
     protected void writeJson(HttpServletResponse resp, Object obj) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.getWriter().write(new Gson().toJson(obj));
     }
 
     protected void writeJson(HttpServletResponse resp, JsonArray jsonArray) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.getWriter().write(jsonArray.toString());
     }
 
     protected void writeJson(HttpServletResponse resp, JsonObject jsonObject) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");
         resp.getWriter().write(jsonObject.toString());
     }
 
     protected void writeJson(HttpServletResponse resp, JsonArray jsonArray, int statusCode)
             throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());

Review Comment:
   Consider using StandardCharsets.UTF_8.name() instead of toString() for better performance. The name() method is specifically designed for charset names, while toString() is a general object method.
   ```suggestion
           resp.setCharacterEncoding(StandardCharsets.UTF_8.name());
           resp.setContentType("application/json");
           resp.getWriter().write(new Gson().toJson(obj));
       }
   
       protected void writeJson(HttpServletResponse resp, JsonArray jsonArray) throws IOException {
           resp.setCharacterEncoding(StandardCharsets.UTF_8.name());
           resp.setContentType("application/json");
           resp.getWriter().write(jsonArray.toString());
       }
   
       protected void writeJson(HttpServletResponse resp, JsonObject jsonObject) throws IOException {
           resp.setCharacterEncoding(StandardCharsets.UTF_8.name());
           resp.setContentType("application/json");
           resp.getWriter().write(jsonObject.toString());
       }
   
       protected void writeJson(HttpServletResponse resp, JsonArray jsonArray, int statusCode)
               throws IOException {
           resp.setCharacterEncoding(StandardCharsets.UTF_8.name());
   ```



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2235708081


##########
seatunnel-engine/seatunnel-engine-server/src/test/resources/log4j2-test.properties:
##########
@@ -18,8 +18,15 @@
 
 rootLogger.level = INFO
 
+property.file_path = ${sys:seatunnel.logs.path:-logs}

Review Comment:
   If this file log4j2-test.properties is removed and no logs directory is generated, calling the API will return the following error:
   java.lang.IllegalArgumentException: Log file path is empty, get logRef : 
   	at org.apache.seatunnel.engine.common.utils.LogUtil.getLogPath(LogUtil.java:54) ~[classes/:?]
   	at org.apache.seatunnel.engine.server.rest.service.BaseLogService.getLogPath(BaseLogService.java:42) ~[classes/:?]



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2230902002


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/BaseServlet.java:
##########
@@ -145,4 +155,36 @@ protected Map<String, String> getParameterMap(HttpServletRequest req) {
         }
         return reqParameterMap;
     }
+
+    @VisibleForTesting
+    public void writeJsonForTest(HttpServletResponse resp, Object obj, String type)
+            throws IOException {
+        switch (type) {
+            case "1":
+                writeJson(resp, obj);
+                break;
+            case "2":
+                writeJson(resp, (JsonArray) obj);
+                break;
+            case "3":
+                writeJson(resp, (JsonObject) obj);
+                break;
+            case "4":
+                writeJson(resp, (JsonArray) obj, 200);
+                break;
+            case "5":
+                writeJson(resp, (JsonObject) obj, 200);
+                break;
+            case "6":
+                writeJson(resp, obj, 200);
+                break;
+            case "7":
+                write(resp, obj);
+                break;
+            case "8":
+                writeHtml(resp, obj);
+                break;
+            default:
+        }
+    }

Review Comment:
   Please do not add intrusive test code in the source code. We can verify the get method response of different servlets. For example https://github.com/apache/seatunnel/blob/e01108a0ef129e7ebb49ed031d85966773713c9b/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/CurrentNodeLogServlet.java#L46



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2234558627


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        // enabled Http
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse();
+    }
+
+    public void testLogRestApiResponse() throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL(
+                            "http://localhost:" + HTTP_PORT + "/logs/job-" + JOB_1 + ".log");
+            conn = (HttpURLConnection) url.openConnection();

Review Comment:
   Maybe it would be a better choice to directly request all logs? https://github.com/apache/seatunnel/blob/3dc79c1ddfbaec93120bfbaf1189aaa49363bd41/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/RestConstant.java#L88
   This way you don't have to overwrite the log4j file. Make the test case more concise.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#issuecomment-3095083046

   Thanks @liucongjy . Could you add test case to check response header?


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X merged PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2234595780


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        // enabled Http
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse();
+    }
+
+    public void testLogRestApiResponse() throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL(
+                            "http://localhost:" + HTTP_PORT + "/logs/job-" + JOB_1 + ".log");
+            conn = (HttpURLConnection) url.openConnection();

Review Comment:
   the /logs endpoint only lists the names of all log files in the logs directory and does not display the specific content of each log file. If you use this /logs API, whether still need to call the /log/job-xxx.log endpoint to retrieve the detailed content of each file?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2218074640


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/BaseServlet.java:
##########
@@ -46,47 +46,55 @@ public BaseServlet(NodeEngineImpl nodeEngine) {
     }
 
     protected void writeJson(HttpServletResponse resp, Object obj) throws IOException {
+        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
         resp.setContentType("application/json");

Review Comment:
    Also specify the charset in Content-Type to ensure the client parses it correctly.  `resp.setContentType("application/json; charset=UTF-8");` 
   



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2235614107


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        // enabled Http
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse();
+    }
+
+    public void testLogRestApiResponse() throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL(
+                            "http://localhost:" + HTTP_PORT + "/logs/job-" + JOB_1 + ".log");
+            conn = (HttpURLConnection) url.openConnection();

Review Comment:
   thank you,modify unit test on this way



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2242726766


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse("html");
+        testLogRestApiResponse("JSON");
+    }
+
+    public void testLogRestApiResponse(String format) throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL("http://localhost:" + HTTP_PORT + "/logs?format=" + format);
+            conn = (HttpURLConnection) url.openConnection();
+
+            Assertions.assertEquals(200, conn.getResponseCode());
+
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));

Review Comment:
   useless too?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2241540330


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse("html");
+        testLogRestApiResponse("JSON");
+    }
+
+    public void testLogRestApiResponse(String format) throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL("http://localhost:" + HTTP_PORT + "/logs?format=" + format);
+            conn = (HttpURLConnection) url.openConnection();
+
+            Assertions.assertEquals(200, conn.getResponseCode());
+
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+            String response = in.lines().collect(Collectors.joining("\r\n"));

Review Comment:
   yes, I've remove it



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2234601515


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        // enabled Http
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse();
+    }
+
+    public void testLogRestApiResponse() throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL(
+                            "http://localhost:" + HTTP_PORT + "/logs/job-" + JOB_1 + ".log");
+            conn = (HttpURLConnection) url.openConnection();

Review Comment:
   Does the process first call the /logs API to retrieve all log files, then call the /logs/job-xxx.log API to request each log file's content, and finally verify whether the returned encoding is correct?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#issuecomment-3130368404

   waiting test case passes.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2238545443


##########
seatunnel-engine/seatunnel-engine-server/src/test/resources/log4j2-test.properties:
##########
@@ -18,8 +18,15 @@
 
 rootLogger.level = INFO
 
+property.file_path = ${sys:seatunnel.logs.path:-logs}

Review Comment:
   thank you,i have restore this file



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2235617337


##########
seatunnel-engine/seatunnel-engine-server/src/test/resources/log4j2-test.properties:
##########
@@ -18,8 +18,15 @@
 
 rootLogger.level = INFO
 
+property.file_path = ${sys:seatunnel.logs.path:-logs}

Review Comment:
   remove this line property.file_path = ${sys:seatunnel.logs.path:-logs} or remove this file log4j2-test.properties?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2235617337


##########
seatunnel-engine/seatunnel-engine-server/src/test/resources/log4j2-test.properties:
##########
@@ -18,8 +18,15 @@
 
 rootLogger.level = INFO
 
+property.file_path = ${sys:seatunnel.logs.path:-logs}

Review Comment:
   remove this line property.file_path = ${sys:seatunnel.logs.path:-logs} or remove this file log4j2-test.properties?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2234925644


##########
seatunnel-engine/seatunnel-engine-server/src/test/resources/log4j2-test.properties:
##########
@@ -18,8 +18,15 @@
 
 rootLogger.level = INFO
 
+property.file_path = ${sys:seatunnel.logs.path:-logs}

Review Comment:
   So I think we can remove this file now.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2236611337


##########
seatunnel-engine/seatunnel-engine-server/src/test/resources/log4j2-test.properties:
##########
@@ -18,8 +18,15 @@
 
 rootLogger.level = INFO
 
+property.file_path = ${sys:seatunnel.logs.path:-logs}

Review Comment:
   oh I got it. Sorry about that. You can revert it without any change.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2241540330


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse("html");
+        testLogRestApiResponse("JSON");
+    }
+
+    public void testLogRestApiResponse(String format) throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL("http://localhost:" + HTTP_PORT + "/logs?format=" + format);
+            conn = (HttpURLConnection) url.openConnection();
+
+            Assertions.assertEquals(200, conn.getResponseCode());
+
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+            String response = in.lines().collect(Collectors.joining("\r\n"));

Review Comment:
   yes, i will remove it



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#issuecomment-3138437518

   waiting test case pass


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2232966475


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/BaseServlet.java:
##########
@@ -145,4 +155,36 @@ protected Map<String, String> getParameterMap(HttpServletRequest req) {
         }
         return reqParameterMap;
     }
+
+    @VisibleForTesting
+    public void writeJsonForTest(HttpServletResponse resp, Object obj, String type)
+            throws IOException {
+        switch (type) {
+            case "1":
+                writeJson(resp, obj);
+                break;
+            case "2":
+                writeJson(resp, (JsonArray) obj);
+                break;
+            case "3":
+                writeJson(resp, (JsonObject) obj);
+                break;
+            case "4":
+                writeJson(resp, (JsonArray) obj, 200);
+                break;
+            case "5":
+                writeJson(resp, (JsonObject) obj, 200);
+                break;
+            case "6":
+                writeJson(resp, obj, 200);
+                break;
+            case "7":
+                write(resp, obj);
+                break;
+            case "8":
+                writeHtml(resp, obj);
+                break;
+            default:
+        }
+    }

Review Comment:
   The test code in the source code has been removed, and unit tests have been re-added to simulate running tasks and making HTTP requests to the log interface to check whether the returned character set is UTF-8



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2234788760


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        // enabled Http
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse();
+    }
+
+    public void testLogRestApiResponse() throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL(
+                            "http://localhost:" + HTTP_PORT + "/logs/job-" + JOB_1 + ".log");
+            conn = (HttpURLConnection) url.openConnection();

Review Comment:
   Call the /logs API to retrieve all log files, then verify whether the returned encoding is correct.
   No need to get detail logs. Because the /logs API will invoke writeJson method too. https://github.com/apache/seatunnel/blob/044bd3cfafae08ec9eb2391f1915184b5adbecbe/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/AllNodeLogServlet.java#L69



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on code in PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#discussion_r2234595780


##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/rest/BaseServletTest.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.seatunnel.engine.server.rest;
+
+import org.apache.seatunnel.engine.common.config.SeaTunnelConfig;
+import org.apache.seatunnel.engine.common.config.server.HttpConfig;
+import org.apache.seatunnel.engine.common.runtime.ExecutionMode;
+import org.apache.seatunnel.engine.common.utils.PassiveCompletableFuture;
+import org.apache.seatunnel.engine.core.dag.logical.LogicalDag;
+import org.apache.seatunnel.engine.core.job.JobImmutableInformation;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+import org.apache.seatunnel.engine.server.SeaTunnelServer;
+import org.apache.seatunnel.engine.server.SeaTunnelServerStarter;
+import org.apache.seatunnel.engine.server.TestUtils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.internal.serialization.Data;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+class BaseServletTest extends AbstractSeaTunnelServerTest {
+
+    private static final int HTTP_PORT = 18080;
+
+    private static final Long JOB_1 = System.currentTimeMillis() + 1L;
+
+    @BeforeEach
+    void setUp() {
+        String name = this.getClass().getName();
+        Config hazelcastConfig = Config.loadFromString(getHazelcastConfig());
+        hazelcastConfig.setClusterName(TestUtils.getClusterName("RestApiServletTest_" + name));
+        SeaTunnelConfig seaTunnelConfig = loadSeaTunnelConfig();
+        seaTunnelConfig.setHazelcastConfig(hazelcastConfig);
+        seaTunnelConfig.getEngineConfig().setMode(ExecutionMode.LOCAL);
+
+        HttpConfig httpConfig = seaTunnelConfig.getEngineConfig().getHttpConfig();
+        // enabled Http
+        httpConfig.setEnabled(true);
+        httpConfig.setPort(HTTP_PORT);
+
+        instance = SeaTunnelServerStarter.createHazelcastInstance(seaTunnelConfig);
+        nodeEngine = instance.node.nodeEngine;
+        server = nodeEngine.getService(SeaTunnelServer.SERVICE_NAME);
+        LOGGER = nodeEngine.getLogger(AbstractSeaTunnelServerTest.class);
+    }
+
+    @Test
+    void testWriteJsonWithObject() throws IOException {
+        startJob(JOB_1, "fake_to_console.conf");
+        testLogRestApiResponse();
+    }
+
+    public void testLogRestApiResponse() throws IOException {
+        HttpURLConnection conn = null;
+        BufferedReader in = null;
+        try {
+            java.net.URL url =
+                    new java.net.URL(
+                            "http://localhost:" + HTTP_PORT + "/logs/job-" + JOB_1 + ".log");
+            conn = (HttpURLConnection) url.openConnection();

Review Comment:
   the /logs endpoint only lists the names of all log files in the logs directory and does not display the specific content of each log file. If you use this /logs API, whether still need to call the /log/job-xxx.log endpoint to retrieve the detailed content of each file?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix][engine-server] Fix the issue of garbled characters in log output [seatunnel]

Posted by "liucongjy (via GitHub)" <gi...@apache.org>.
liucongjy commented on PR #9594:
URL: https://github.com/apache/seatunnel/pull/9594#issuecomment-3106341179

   > Thanks @liucongjy . Could you add test case to check response header?
   
   Hi,Unit tests have been added in the org/apache/seatunnel/engine/server/rest/BaseServletTest.java class


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org