Skip to content
Browse files

bug fixed for oom & public long field

  • Loading branch information...
1 parent 00f08fa commit 1811cc8b392ad9f3e3bbae17b00d52ccfd8a4d08 wenshao committed
View
7 src/main/java/com/alibaba/fastjson/parser/deserializer/ASMDeserializerFactory.java
@@ -512,7 +512,12 @@ private void _batchSet(Context context, MethodVisitor mw) {
mw.visitVarInsn(ILOAD, context.var(fieldInfo.getName() + "_asm"));
} else if (fieldClass == long.class) {
mw.visitVarInsn(LLOAD, context.var(fieldInfo.getName() + "_asm", 2));
- mw.visitMethodInsn(INVOKEVIRTUAL, getType(context.getClazz()), fieldInfo.getMethod().getName(), "(J)V");
+ if (fieldInfo.getMethod() != null) {
+ mw.visitMethodInsn(INVOKEVIRTUAL, getType(context.getClazz()), fieldInfo.getMethod().getName(), "(J)V");
+ } else {
+ mw.visitFieldInsn(PUTFIELD, getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(),
+ getDesc(fieldInfo.getFieldClass()));
+ }
continue;
} else if (fieldClass == float.class) {
mw.visitVarInsn(FLOAD, context.var(fieldInfo.getName() + "_asm"));
View
20 src/test/java/com/alibaba/json/bvt/OOMTest.java
@@ -0,0 +1,20 @@
+package com.alibaba.json.bvt;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.parser.ParserConfig;
+import com.alibaba.fastjson.parser.SymbolTable;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class OOMTest extends TestCase {
+ public void test_oom() throws Exception {
+
+ for (int i = 0; i < 1000 * 1000; ++i) {
+ String text = "{\"" + i + "\":0}";
+ JSON.parse(text);
+ }
+
+ Assert.assertEquals(SymbolTable.MAX_SIZE, ParserConfig.getGlobalInstance().getSymbolTable().size());
+ }
+}
View
25 src/test/java/com/alibaba/json/bvt/PublicFieldDoubleTest.java
@@ -0,0 +1,25 @@
+package com.alibaba.json.bvt;
+
+import com.alibaba.fastjson.JSON;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class PublicFieldDoubleTest extends TestCase {
+
+ public static class VO {
+
+ public double id;
+ }
+
+ public void test_codec() throws Exception {
+ VO vo = new VO();
+ vo.id = 12.34;
+
+ String str = JSON.toJSONString(vo);
+
+ VO vo1 = JSON.parseObject(str, VO.class);
+
+ Assert.assertEquals(vo1.id, vo.id);
+ }
+}
View
25 src/test/java/com/alibaba/json/bvt/PublicFieldFloatTest.java
@@ -0,0 +1,25 @@
+package com.alibaba.json.bvt;
+
+import com.alibaba.fastjson.JSON;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class PublicFieldFloatTest extends TestCase {
+
+ public static class VO {
+
+ public float id;
+ }
+
+ public void test_codec() throws Exception {
+ VO vo = new VO();
+ vo.id = 123.4F;
+
+ String str = JSON.toJSONString(vo);
+
+ VO vo1 = JSON.parseObject(str, VO.class);
+
+ Assert.assertEquals(vo1.id, vo.id);
+ }
+}
View
25 src/test/java/com/alibaba/json/bvt/PublicFieldLongTest.java
@@ -0,0 +1,25 @@
+package com.alibaba.json.bvt;
+
+import com.alibaba.fastjson.JSON;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class PublicFieldLongTest extends TestCase {
+
+ public static class VO {
+
+ public long id;
+ }
+
+ public void test_codec() throws Exception {
+ VO vo = new VO();
+ vo.id = 1234;
+
+ String str = JSON.toJSONString(vo);
+
+ VO vo1 = JSON.parseObject(str, VO.class);
+
+ Assert.assertEquals(vo1.id, vo.id);
+ }
+}
View
25 src/test/java/com/alibaba/json/bvt/PublicFieldStringTest.java
@@ -0,0 +1,25 @@
+package com.alibaba.json.bvt;
+
+import com.alibaba.fastjson.JSON;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class PublicFieldStringTest extends TestCase {
+
+ public static class VO {
+
+ public String id;
+ }
+
+ public void test_codec() throws Exception {
+ VO vo = new VO();
+ vo.id = "x12345";
+
+ String str = JSON.toJSONString(vo);
+
+ VO vo1 = JSON.parseObject(str, VO.class);
+
+ Assert.assertEquals(vo1.id, vo.id);
+ }
+}
View
12 src/test/java/com/alibaba/json/bvt/bug/Bug_for_dragoon.java
@@ -0,0 +1,12 @@
+package com.alibaba.json.bvt.bug;
+
+import junit.framework.TestCase;
+
+import com.alibaba.fastjson.JSON;
+
+public class Bug_for_dragoon extends TestCase {
+ public void test_for_dragoon() throws Exception {
+ String text = "[{\"S\":93803,\"T\":\"HSMonitorData\"},{\"D\":\"H4sIAAAAAAAAAO1b3W8bxxF/7n9xvRqFipKX+ySPBARYkdVGqS2pEu0UJQVhebckzzzeXu9DNqPqIQECpCiaBG0fWthNH2oDRT8egqKI4LTxP2Pazn+R2d078sQvW7KdWMFakMib2f3N7M7szNzduHkkozDcSgdyXfaS9KD37gHyw4MExX25JDvE97GTXEEJluuaYZo1Q63o1ZphAy/CQJ5i2bah5ayGN8DXPN+PZ/g4SCIPA/1IXidpkMh1vSRfRXHS6EXk1hSkVjOsAvcajmPUhQHyRhSRSBqQwEvg0yddRWpGOCRRsumuchUOSOTiqCRFqY/XSdDxuqsOGSjI99qojZRsruIwlrI7HnXZcNp6260ZTTrzZ3i4Sj8VhvZGGtzCuI8D941aWbNLMNn1Eo8E8erR+Ltyi0R9Fw2XiQvJTaJc47T1fOLlKmo7mqtWStIErEfS6OxIlqlZbcN1i0gDL0gTHJ8DzHGNmmu2j0vIyRbLvyi3UNClv8+LucamXXYdDWsOLkkZDB4gzz8jhmE4HaRX1WNqhASAcAR6HZcY1lUvTlab+6UBaXs+zq9ybfNratfn84lL9Otls63ZGjKa+UZqailIB20cbXeov8erFmBi5PMLteTFMDuBwXi1g/wYgz7cgVd/2dgefXhn9MWD0f/eH52cfF9qBU+//MPog/v1o5YcwRKifkuut2Q37rTkUkt2UNQlW2iAM6rLyQlJkL/FVACGYQCJrn6LsGGabphWhQ2MwWPZGIBHrhuBGnARpL4PzCDH/eqffxp9+fmTB//hMskgRMFwLPXRyb9Hd/6/9sMbj+/+5qs/fzL64F+jj0/YyDAih17g8GGjzz57dHL3yd33OIiXDDn57+89/u/no5P3M2w4+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nYwyYslPAiTYTEK0S4KqA8S5PfjxQ2Q1RdtgFT4XY6SiSpGollSViqZFH/5ShY5/qTJbYFU4e4X0t2fp/5hHhOLJkPRZCiaDEWT4TfdZCj+68cFqJcvzG2YOnMbJrKbyG4iu4ns9m210ItG7e9gPhSN2qJRW/Q9iL4H0fdwcfseRKO2CLEixIoQK0KsaNQWjdqiUVs0aotsKrKpyKavbTYVjdqiUVs0aotG7TM3Ku1/DWGrUgYEWwAA\"}]";
+ JSON.parse(text);
+ }
+}
View
45 src/test/java/com/alibaba/json/bvt/bug/Bug_for_jrz1717.java
@@ -0,0 +1,45 @@
+package com.alibaba.json.bvt.bug;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Bug_for_jrz1717 {
+
+ public static class User {
+
+ private Set<String> authorityCodes = new HashSet<String>();
+
+ private Org currentOrganization;
+
+ public Set<String> getAuthorityCodes() {
+ return authorityCodes;
+ }
+
+ public void setAuthorityCodes(Set<String> authorityCodes) {
+ this.authorityCodes = authorityCodes;
+ }
+
+ public Org getCurrentOrganization() {
+ return currentOrganization;
+ }
+
+ public void setCurrentOrganization(Org currentOrganization) {
+ this.currentOrganization = currentOrganization;
+ }
+
+ }
+
+ public static class Org {
+
+ public Org parent;
+
+ public Org getParent() {
+ return parent;
+ }
+
+ public void setParent(Org parent) {
+ this.parent = parent;
+ }
+
+ }
+}

0 comments on commit 1811cc8

Please sign in to comment.
Something went wrong with that request. Please try again.