From 8e03be34ec7fbef12e84959a2a3c9c64d921f371 Mon Sep 17 00:00:00 2001 From: Sam V Jose Date: Sat, 8 Apr 2023 13:15:51 +0530 Subject: [PATCH] #3019 Issue: Used an alternative API and specified a Charset name or Charset object explicitly. --- .../runtime/admin/handler/TCPClientHandler.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 {