This is an automated email from the ASF dual-hosted git repository.
yuzhou pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 330dccc6b4 [ISSUE #10107] Fix fastjson2 integer overflow when parsing
AtomicLong (#10112)
330dccc6b4 is described below
commit 330dccc6b461d870378b17392d8ea6b059fe1bce
Author: yx9o <[email protected]>
AuthorDate: Wed Feb 25 09:29:22 2026 +0800
[ISSUE #10107] Fix fastjson2 integer overflow when parsing AtomicLong
(#10112)
---
WORKSPACE | 4 +--
pom.xml | 2 +-
.../remoting/protocol/DataVersionTest.java | 36 ++++++++++++++++------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/WORKSPACE b/WORKSPACE
index e0ebfce780..328c43995c 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -41,7 +41,7 @@ maven_install(
artifacts = [
"junit:junit:4.13.2",
"com.alibaba:fastjson:1.2.76",
- "com.alibaba.fastjson2:fastjson2:2.0.43",
+ "com.alibaba.fastjson2:fastjson2:2.0.59",
"org.hamcrest:hamcrest-library:1.3",
"io.netty:netty-all:4.1.65.Final",
"org.assertj:assertj-core:3.22.0",
@@ -112,7 +112,7 @@ maven_install(
"com.alipay.sofa:hessian:3.3.6",
"io.netty:netty-tcnative-boringssl-static:2.0.48.Final",
"org.mockito:mockito-junit-jupiter:4.11.0",
- "com.alibaba.fastjson2:fastjson2:2.0.43",
+ "com.alibaba.fastjson2:fastjson2:2.0.59",
"org.junit.jupiter:junit-jupiter-api:5.9.1",
],
fetch_sources = True,
diff --git a/pom.xml b/pom.xml
index 37cff546cd..f28beaf9e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,7 +105,7 @@
<netty.tcnative.version>2.0.53.Final</netty.tcnative.version>
<bcpkix-jdk18on.version>1.83</bcpkix-jdk18on.version>
<fastjson.version>1.2.83</fastjson.version>
- <fastjson2.version>2.0.43</fastjson2.version>
+ <fastjson2.version>2.0.59</fastjson2.version>
<javassist.version>3.20.0-GA</javassist.version>
<jna.version>4.2.2</jna.version>
<commons-lang3.version>3.20.0</commons-lang3.version>
diff --git
a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/DataVersionTest.java
b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/DataVersionTest.java
index dccedde491..5cf69ae54f 100644
---
a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/DataVersionTest.java
+++
b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/DataVersionTest.java
@@ -17,10 +17,16 @@
package org.apache.rocketmq.remoting.protocol;
-import java.util.concurrent.atomic.AtomicLong;
-import org.junit.Assert;
+import com.alibaba.fastjson2.JSON;
import org.junit.Test;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public class DataVersionTest {
@Test
@@ -28,7 +34,7 @@ public class DataVersionTest {
DataVersion dataVersion = new DataVersion();
DataVersion other = new DataVersion();
other.setTimestamp(dataVersion.getTimestamp());
- Assert.assertTrue(dataVersion.equals(other));
+ assertEquals(dataVersion, other);
}
@Test
@@ -37,7 +43,7 @@ public class DataVersionTest {
DataVersion other = new DataVersion();
other.setCounter(new AtomicLong(1L));
other.setTimestamp(dataVersion.getTimestamp());
- Assert.assertFalse(dataVersion.equals(other));
+ assertNotEquals(dataVersion, other);
}
@Test
@@ -46,7 +52,7 @@ public class DataVersionTest {
DataVersion other = new DataVersion();
other.setCounter(null);
other.setTimestamp(dataVersion.getTimestamp());
- Assert.assertFalse(dataVersion.equals(other));
+ assertNotEquals(dataVersion, other);
}
@Test
@@ -55,7 +61,7 @@ public class DataVersionTest {
dataVersion.setCounter(null);
DataVersion other = new DataVersion();
other.setTimestamp(dataVersion.getTimestamp());
- Assert.assertFalse(dataVersion.equals(other));
+ assertNotEquals(dataVersion, other);
}
@Test
@@ -65,13 +71,25 @@ public class DataVersionTest {
DataVersion other = new DataVersion();
other.setCounter(null);
other.setTimestamp(dataVersion.getTimestamp());
- Assert.assertTrue(dataVersion.equals(other));
+ assertEquals(dataVersion, other);
}
@Test
public void testEncode() {
DataVersion dataVersion = new DataVersion();
- Assert.assertTrue(dataVersion.encode().length > 0);
- Assert.assertNotNull(dataVersion.toJson());
+ assertTrue(dataVersion.encode().length > 0);
+ assertNotNull(dataVersion.toJson());
+ }
+
+ @Test
+ public void testJsonSerializationAndDeserialization() {
+ DataVersion expected = new DataVersion();
+ expected.setCounter(new AtomicLong(Long.MAX_VALUE));
+ expected.setTimestamp(expected.getTimestamp());
+ String jsonStr = expected.toJson();
+ assertNotNull(jsonStr);
+ DataVersion actual = JSON.parseObject(jsonStr, DataVersion.class);
+ assertNotNull(actual);
+ assertEquals(expected.getTimestamp(), actual.getTimestamp());
}
}