From 1db65217950fa27fff3318c2f8d875a3cee434d8 Mon Sep 17 00:00:00 2001 From: liruilin <2858459174@qq.com> Date: Thu, 12 Dec 2024 15:54:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/tongtech/proxy/Client.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java b/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java index 286cc0a..2222a96 100644 --- a/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java +++ b/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java @@ -483,13 +483,19 @@ public class Client { msg = buf.toString(); } else { if (msg != null) { - if (msg.indexOf("\\r") >= 0) { - msg = msg.replace("\\r", "\r"); - } - msg = msg.trim() + "\n"; + msg = msg.replace("\\r", "\r"); + msg = msg.trim() + System.lineSeparator(); } else { - msg = "\\n"; + msg = System.lineSeparator(); } +// if (msg != null) { +// if (msg.indexOf("\\r") >= 0) { +// msg = msg.replace("\\r", "\r"); +// } +// msg = msg.trim() + "\n"; +// } else { +// msg = "\\n"; +// } } if (cluster && isClustercmd) { for (Socket s : Sockets.keySet()) { -- Gitee From 586549d26270ee17f781bafcb201287a63a77ff7 Mon Sep 17 00:00:00 2001 From: liruilin <2858459174@qq.com> Date: Fri, 13 Dec 2024 16:44:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?client=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/tongtech/proxy/Client.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java b/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java index 2222a96..4abaab5 100644 --- a/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java +++ b/rds-proxy/proxy/src/main/java/com/tongtech/proxy/Client.java @@ -466,20 +466,31 @@ public class Client { if (redis_wrapper) { StringBuilder buf = new StringBuilder(); buf.append('*').append(data.size()).append("\r\n"); + for (String s : data) { - int len = -1; - if (s != null) { - if (s.length() == 0) { - len = 0; - } else { - len = s.getBytes(StandardCharsets.UTF_8).length; - } + if (s == null) { + continue; } + int len = s.isEmpty() ? 0 : s.getBytes(StandardCharsets.UTF_8).length; buf.append('$').append(len).append("\r\n"); if (len >= 0) { buf.append(s).append("\r\n"); } } +// for (String s : data) { +// int len = -1; +// if (s != null) { +// if (s.length() == 0) { +// len = 0; +// } else { +// len = s.getBytes(StandardCharsets.UTF_8).length; +// } +// } +// buf.append('$').append(len).append("\r\n"); +// if (len >= 0) { +// buf.append(s).append("\r\n"); +// } +// } msg = buf.toString(); } else { if (msg != null) { -- Gitee