diff --git a/core/src/test/java/com/alibaba/fastjson2/issues_3700/Issue3763.java b/core/src/test/java/com/alibaba/fastjson2/issues_3700/Issue3763.java new file mode 100644 index 000000000..2b6de6cfb --- /dev/null +++ b/core/src/test/java/com/alibaba/fastjson2/issues_3700/Issue3763.java @@ -0,0 +1,37 @@ +package com.alibaba.fastjson2.issues_3700; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.TypeReference; +import org.junit.jupiter.api.Test; + +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +public class Issue3763 { + @Test + public void test() throws Throwable { + String str = "{\"queryParam\":{},\"columnOrderParam\":[{\"field\":\"RTIME\",\"sortType\":\"DESC\"}],\"simpleQueryParam\":[],\"columnFilterParam\":[{\"field\":\"XXXX$USER_ID\",\"dateFormat\":\"\",\"value\":\"\",\"fieldValueRel\":\"like\",\"conditionRel\":\"and\",\"conditions\":[{\"expression\":\"eq\",\"value\":\"77c21b37d87e457e8669508310420ed7\"},{\"expression\":\"eq\",\"value\":\"\"}]}]}"; + + final int taskCount = 100; + CountDownLatch startLatch = new CountDownLatch(1); + CountDownLatch endLatch = new CountDownLatch(taskCount); + Thread[] threads = new Thread[taskCount]; + for (int i = 0; i < taskCount; i++) { + threads[i] = new Thread(() -> { + try { + startLatch.await(); + JSON.parseObject(str, new TypeReference>() { + }); + JSON.parseObject(str); + } catch (InterruptedException ignored) { + // ignore + } finally { + endLatch.countDown(); + } + }); + threads[i].start(); + } + startLatch.countDown(); + endLatch.await(); + } +} diff --git a/fastjson1-compatible/src/test/java/com/alibaba/fastjson2/issue_3700/Issue3763.java b/fastjson1-compatible/src/test/java/com/alibaba/fastjson2/issue_3700/Issue3763.java new file mode 100644 index 000000000..07f805f5d --- /dev/null +++ b/fastjson1-compatible/src/test/java/com/alibaba/fastjson2/issue_3700/Issue3763.java @@ -0,0 +1,34 @@ +package com.alibaba.fastjson2.issue_3700; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.CountDownLatch; + +public class Issue3763 { + @Test + public void test() throws Throwable { + String str = "{\"queryParam\":{},\"columnOrderParam\":[{\"field\":\"RTIME\",\"sortType\":\"DESC\"}],\"simpleQueryParam\":[],\"columnFilterParam\":[{\"field\":\"XXXX$USER_ID\",\"dateFormat\":\"\",\"value\":\"\",\"fieldValueRel\":\"like\",\"conditionRel\":\"and\",\"conditions\":[{\"expression\":\"eq\",\"value\":\"77c21b37d87e457e8669508310420ed7\"},{\"expression\":\"eq\",\"value\":\"\"}]}]}"; + + final int taskCount = 100; + CountDownLatch startLatch = new CountDownLatch(1); + CountDownLatch endLatch = new CountDownLatch(taskCount); + Thread[] threads = new Thread[taskCount]; + for (int i = 0; i < taskCount; i++) { + threads[i] = new Thread(() -> { + try { + startLatch.await(); + JSONObject.parseObject(str, Feature.OrderedField); + } catch (InterruptedException ignored) { + // ignore + } finally { + endLatch.countDown(); + } + }); + threads[i].start(); + } + startLatch.countDown(); + endLatch.await(); + } +}