From dda0ee2c43a2c2fc7b6ab20ddef6c25ce07e6874 Mon Sep 17 00:00:00 2001 From: shanwb Date: Wed, 1 Nov 2023 09:55:24 +0800 Subject: [PATCH 1/2] fix mvc request method (#749) --- jcommon/docean/pom.xml | 2 +- .../src/main/java/com/xiaomi/youpin/docean/Mvc.java | 8 +++++++- jcommon/pom.xml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jcommon/docean/pom.xml b/jcommon/docean/pom.xml index 9cb9692d4..7edcd45d1 100644 --- a/jcommon/docean/pom.xml +++ b/jcommon/docean/pom.xml @@ -10,7 +10,7 @@ 4.0.0 docean - 1.4.0 + 1.4.1-SNAPSHOT 4.1.48.Final diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java index 66dbc6346..53c4a5543 100644 --- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java +++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java @@ -161,8 +161,14 @@ public void callService(MvcContext context, MvcRequest request, MvcResponse resp public void callMethod(MvcContext context, MvcRequest request, MvcResponse response, MvcResult result, HttpRequestMethod method) { Safe.run(() -> { - JsonElement arguments = gson.fromJson(new String(request.getBody()), JsonElement.class); + //GET、POST + String reqMethod = request.getMethod(); String m = method.getHttpMethod(); + if (!m.equalsIgnoreCase(reqMethod)) { + throw new IllegalArgumentException(String.format("unmatched request type:%s, expect:%s", reqMethod, m.toUpperCase())); + } + + JsonElement arguments = gson.fromJson(new String(request.getBody()), JsonElement.class); MutableObject mo = getArgs(method, arguments, m); Safe.run(() -> context.setParams(arguments)); JsonElement args = mo.getObj(); diff --git a/jcommon/pom.xml b/jcommon/pom.xml index b81e73f37..a07296975 100644 --- a/jcommon/pom.xml +++ b/jcommon/pom.xml @@ -261,7 +261,7 @@ gpg - your-gpg-key + From dfe24f9f7edda4a79a80201268b512a7d4cd4d9b Mon Sep 17 00:00:00 2001 From: shanwb Date: Tue, 9 Apr 2024 15:00:07 +0800 Subject: [PATCH 2/2] fix field access --- .../com/xiaomi/data/push/redis/ext/PipelineClusterCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jcommon/redis/src/main/java/com/xiaomi/data/push/redis/ext/PipelineClusterCommand.java b/jcommon/redis/src/main/java/com/xiaomi/data/push/redis/ext/PipelineClusterCommand.java index 6af38c322..9d4b00354 100644 --- a/jcommon/redis/src/main/java/com/xiaomi/data/push/redis/ext/PipelineClusterCommand.java +++ b/jcommon/redis/src/main/java/com/xiaomi/data/push/redis/ext/PipelineClusterCommand.java @@ -130,6 +130,7 @@ private Map> getPoolKeyMap(List keys) { Map> poolKeysMap = new LinkedHashMap>(); try { Field field = JedisClusterConnectionHandler.class.getDeclaredField("cache"); + field.setAccessible(true); for (String key : keys) { JedisPool jedisPool; int slot = JedisClusterCRC16.getSlot(key);