This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new 51ff20ac7 [ISSUE #3018] Found reliance on default encoding:
String.getBytes() [RegistryHandler] (#3781)
51ff20ac7 is described below
commit 51ff20ac7314fbc7f06ec97b6887cd766f5042f2
Author: Piyush <[email protected]>
AuthorDate: Thu May 4 07:38:52 2023 +0530
[ISSUE #3018] Found reliance on default encoding: String.getBytes()
[RegistryHandler] (#3781)
* Updated RegistryHandler.java #3018
* Update RegistryHandler.java
* Update RegistryHandler.java
---------
Co-authored-by: mike_xwm <[email protected]>
---
.../eventmesh/runtime/admin/handler/RegistryHandler.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java
index 8c9026614..c70835974 100755
---
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java
+++
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/handler/RegistryHandler.java
@@ -18,6 +18,7 @@
package org.apache.eventmesh.runtime.admin.handler;
import org.apache.eventmesh.api.registry.dto.EventMeshDataInfo;
+import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager;
import org.apache.eventmesh.runtime.admin.response.Error;
@@ -86,13 +87,13 @@ public class RegistryHandler extends AbstractHttpHandler {
getRegistryResponseList.sort(Comparator.comparing(GetRegistryResponse::getEventMeshClusterName));
String result = JsonUtils.toJSONString(getRegistryResponseList);
- 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 (NullPointerException e) {
//registry not initialized, return empty list
String result = JsonUtils.toJSONString(new ArrayList<>());
- 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);
@@ -102,8 +103,8 @@ public class RegistryHandler extends AbstractHttpHandler {
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 {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]