This is an automated email from the ASF dual-hosted git repository.
moremind pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 4835f40f80 chore: upgrade gson version (#7564)
4835f40f80 is described below
commit 4835f40f8053c1b7d11a0373cdb1bd4678440195
Author: shown <[email protected]>
AuthorDate: Mon Oct 12 16:14:59 2026 +0800
chore: upgrade gson version (#7564)
* chore: upgrade gson version
Signed-off-by: yuluo-yx <[email protected]>
* test: fix websocket snapshot verification
Signed-off-by: yuluo-yx <[email protected]>
* test: specify response type for empty HTTP body
Signed-off-by: yuluo-yx <[email protected]>
---------
Signed-off-by: yuluo-yx <[email protected]>
---
pom.xml | 2 +-
.../java/org/apache/shenyu/common/utils/GsonUtilsTest.java | 14 +++++++++++++-
shenyu-integrated-test/pom.xml | 1 -
.../integrated/test/http/HttpTestControllerTest.java | 2 +-
.../data/websocket/handler/WebsocketDataHandlerTest.java | 2 +-
5 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 520fb72d51..f14501fa8e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,7 +121,7 @@
<kryo.version>4.0.0</kryo.version>
<pagehelper.version>5.3.3</pagehelper.version>
<apache.dubbo.version>3.2.14</apache.dubbo.version>
- <gson.version>2.9.0</gson.version>
+ <gson.version>2.13.2</gson.version>
<okhttp.version>4.9.3</okhttp.version>
<prometheus-java-client.version>0.15.0</prometheus-java-client.version>
<prometheus-jmx.version>0.15.0</prometheus-jmx.version>
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
index 1737453b77..121a0d4bd5 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/GsonUtilsTest.java
@@ -37,6 +37,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -335,8 +336,19 @@ public class GsonUtilsTest {
String json = "[{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"},"
+ "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"},"
+ "{\"name\":\"test\",\"id\":\"123\",\"data\":\"测试\"}]";
- List<? extends Map> testList =
GsonUtils.getInstance().fromCurrentList(json, map.getClass());
+ List<? extends Map> testList =
GsonUtils.getInstance().fromCurrentList(json, Map.class);
Assertions.assertEquals(list, testList);
+ assertTrue(testList instanceof CopyOnWriteArrayList);
+ }
+
+ @Test
+ public void testFromCurrentListPreservesElementType() {
+ TestObject expected = generateTestObject();
+ List<TestObject> actual = GsonUtils.getInstance().fromCurrentList(
+ GsonUtils.getInstance().toJson(List.of(expected)),
TestObject.class);
+ assertTrue(actual instanceof CopyOnWriteArrayList);
+ assertEquals(1, actual.size());
+ assertEquals(expected, actual.get(0));
}
private static class TestObject {
diff --git a/shenyu-integrated-test/pom.xml b/shenyu-integrated-test/pom.xml
index f6850e8aa9..5e243fe33c 100644
--- a/shenyu-integrated-test/pom.xml
+++ b/shenyu-integrated-test/pom.xml
@@ -53,7 +53,6 @@
<versions-maven-plugin.version>2.5</versions-maven-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-cloud.version>4.1.2</spring-cloud.version>
- <gson.version>2.9.0</gson.version>
<okhttp3.version>4.9.3</okhttp3.version>
<!-- <curator.version>4.0.1</curator.version>-->
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/HttpTestControllerTest.java
b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/HttpTestControllerTest.java
index aae5a984a3..96eebba0c3 100644
---
a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/HttpTestControllerTest.java
+++
b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/HttpTestControllerTest.java
@@ -221,7 +221,7 @@ public final class HttpTestControllerTest extends
AbstractTest {
@Test
public void testResponseBodyIsNull() throws IOException {
- Object result =
HttpHelper.INSTANCE.getFromGateway("/http/test/nullResponse", null);
+ Object result =
HttpHelper.INSTANCE.getFromGateway("/http/test/nullResponse", Object.class);
assertNull(result);
}
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/WebsocketDataHandlerTest.java
b/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/WebsocketDataHandlerTest.java
index 12ecff787e..403ea262af 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/WebsocketDataHandlerTest.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/WebsocketDataHandlerTest.java
@@ -134,7 +134,7 @@ public final class WebsocketDataHandlerTest {
websocketDataHandler.snapshot(ConfigGroupEnum.PLUGIN, "[]",
"namespace-a", "namespace-a");
websocketDataHandler.executor(ConfigGroupEnum.PLUGIN, json,
DataEventTypeEnum.REFRESH.name());
Mockito.verify(pluginDataSubscriber,
Mockito.times(2)).refreshPluginDataAll();
-
Mockito.verify(pluginDataSubscriber).refreshPluginDataNamespace("namespace-a");
+
Mockito.verify(pluginDataSubscriber).applyPluginDataSnapshot("namespace-a",
Collections.emptyList());
}
@Test