Repository: alibaba/fastjson2 (java)

Issue:
[BUG] 使用 UseBigDecimalForDoubles 解析浮点数，小数点漂移
### 问题描述
使用 UseBigDecimalForDoubles 解析浮点数，小数点漂移

### 环境信息
 - OS信息：  macOS 15.3.1
 - JDK信息： OpenJDK 17.0.14
 - 版本信息：Fastjson2 2.0.56

### 重现步骤

```java
String str = "{\"val\":2.503705945562304E-5}";
JSONObject object = JSON.parseObject(str, JSONReader.Feature.UseBigDecimalForDoubles);
Object val = object.get("val");
assertEquals(BigDecimal.class, val.getClass());
System.out.println(object);
```

### 期待的正确结果
- 预期：{"val":0.00002503705945562304}
- 实际：{"val":2.503705945562304}

Pull request description:
fix JSONReader.Feature.UseBigDecimalForDoubles when exponent != 0 (#3382)
fix #3382 

Patch:
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index d06299ddb..e122f3770 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -112,7 +112,7 @@
         <dependency>
             <groupId>org.apache.fury</groupId>
             <artifactId>fury-core</artifactId>
-            <version>0.9.0</version>
+            <version>0.10.0</version>
         </dependency>
         <dependency>
             <groupId>org.msgpack</groupId>
diff --git a/benchmark_21/pom.xml b/benchmark_21/pom.xml
index c18242582..5b263454a 100644
--- a/benchmark_21/pom.xml
+++ b/benchmark_21/pom.xml
@@ -114,7 +114,7 @@
         <dependency>
             <groupId>org.apache.fury</groupId>
             <artifactId>fury-core</artifactId>
-            <version>0.9.0</version>
+            <version>0.10.0</version>
         </dependency>
         <dependency>
             <groupId>org.msgpack</groupId>
diff --git a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java
index f28b2daba..8eb040587 100644
--- a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java
+++ b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java
@@ -3093,10 +3093,13 @@ public abstract class JSONReader
                     }
                 }
 
-                if (exponent != 0 && (context.features & (Feature.UseBigDecimalForDoubles.mask | Feature.UseBigDecimalForFloats.mask)) == 0) {
+                if (exponent != 0) {
                     String decimalStr = decimal.toPlainString();
-                    return Double.parseDouble(
-                            decimalStr + "E" + exponent);
+                    if ((context.features & (Feature.UseBigDecimalForDoubles.mask | Feature.UseBigDecimalForFloats.mask)) == 0) {
+                        return Double.parseDouble(
+                                decimalStr + "E" + exponent);
+                    }
+                    return decimal.signum() == 0 ? BigDecimal.ZERO : new BigDecimal(decimalStr + "E" + exponent);
                 }
 
                 if ((context.features & Feature.UseDoubleForDecimals.mask) != 0) {
diff --git a/fastjson1-compatible/pom.xml b/fastjson1-compatible/pom.xml
index f0c688bf2..998178d30 100644
--- a/fastjson1-compatible/pom.xml
+++ b/fastjson1-compatible/pom.xml
@@ -285,7 +285,7 @@
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy</artifactId>
-            <version>3.0.22</version>
+            <version>3.0.24</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/pom.xml b/pom.xml
index 1c09b29ea..932504109 100644
--- a/pom.xml
+++ b/pom.xml
@@ -197,7 +197,7 @@
             <dependency>
                 <groupId>com.google.guava</groupId>
                 <artifactId>guava</artifactId>
-                <version>33.3.0-jre</version>
+                <version>33.4.0-jre</version>
             </dependency>
             <dependency>
                 <groupId>com.google.protobuf</groupId>


Test patch:
diff --git a/core/src/test/java/com/alibaba/fastjson2/issues_3300/Issue3382.java b/core/src/test/java/com/alibaba/fastjson2/issues_3300/Issue3382.java
new file mode 100644
index 000000000..4a440e088
--- /dev/null
+++ b/core/src/test/java/com/alibaba/fastjson2/issues_3300/Issue3382.java
@@ -0,0 +1,20 @@
+package com.alibaba.fastjson2.issues_3300;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONReader;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class Issue3382 {
+    @Test
+    public void test() throws Exception {
+        String str = "2.503705945562304E-5";
+        BigDecimal expected = new BigDecimal(str).stripTrailingZeros();
+
+        BigDecimal decimal = (BigDecimal) JSON.parse(str, JSONReader.Feature.UseBigDecimalForDoubles);
+        assertEquals(expected, decimal);
+    }
+}