diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java index b1245f9c90..28fcca9e02 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/TCPClientHandler.java @@ -17,6 +17,7 @@ package org.apache.eventmesh.runtime.admin.handler; +import org.apache.eventmesh.common.Constants; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.common.utils.JsonUtils; import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; @@ -111,8 +112,8 @@ void delete(HttpExchange httpExchange) throws IOException { Error error = new Error(e.toString(), stackTrace); String result = JsonUtils.toJSONString(error); - httpExchange.sendResponseHeaders(500, result.getBytes().length); - out.write(result.getBytes()); + httpExchange.sendResponseHeaders(500, result.getBytes(Constants.DEFAULT_CHARSET).length); + out.write(result.getBytes(Constants.DEFAULT_CHARSET)); } finally { if (out != null) { try { @@ -163,8 +164,8 @@ void list(HttpExchange httpExchange) throws IOException { }); String result = JsonUtils.toJSONString(getClientResponseList); - httpExchange.sendResponseHeaders(200, result.getBytes().length); - out.write(result.getBytes()); + httpExchange.sendResponseHeaders(200, result.getBytes(Constants.DEFAULT_CHARSET).length); + out.write(result.getBytes(Constants.DEFAULT_CHARSET)); } catch (Exception e) { StringWriter writer = new StringWriter(); PrintWriter printWriter = new PrintWriter(writer); @@ -174,8 +175,8 @@ void list(HttpExchange httpExchange) throws IOException { Error error = new Error(e.toString(), stackTrace); String result = JsonUtils.toJSONString(error); - httpExchange.sendResponseHeaders(500, result.getBytes().length); - out.write(result.getBytes()); + httpExchange.sendResponseHeaders(500, result.getBytes(Constants.DEFAULT_CHARSET).length); + out.write(result.getBytes(Constants.DEFAULT_CHARSET)); } finally { if (out != null) { try {