-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
core/src/test/java/com/alibaba/fastjson2/issues/Issue661.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.alibaba.fastjson2.issues; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.RepeatedTest; | ||
|
||
import java.util.Collections; | ||
|
||
public class Issue661 { | ||
@Data | ||
static class Response<T> { | ||
T data; | ||
|
||
Response(T data) { | ||
this.data = data; | ||
} | ||
} | ||
|
||
@Data | ||
static class A { | ||
// 没有属性不会异常 | ||
int a; | ||
} | ||
|
||
@RepeatedTest(100) | ||
void testB() { | ||
for (int i = 0; i < 1000; i++) { | ||
JSON.toJSONString(new Response<>(new A())); | ||
} | ||
} | ||
|
||
@RepeatedTest(100) | ||
void testList() { | ||
for (int i = 0; i < 1000; i++) { | ||
// Collections.singletonList(0)改成0也会异常,异常概率小一些 | ||
JSON.toJSONString(new Response<>(Collections.singletonList(0))); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
fastjson1-compatible/src/test/java/com/alibaba/fastjson/v2issues/Issue661.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.alibaba.fastjson.v2issues; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.RepeatedTest; | ||
|
||
import java.util.Collections; | ||
|
||
public class Issue661 { | ||
@Data | ||
static class Response<T> { | ||
T data; | ||
|
||
Response(T data) { | ||
this.data = data; | ||
} | ||
} | ||
|
||
@Data | ||
static class A { | ||
// 没有属性不会异常 | ||
int a; | ||
} | ||
|
||
@RepeatedTest(100) | ||
void testB() { | ||
for (int i = 0; i < 1000; i++) { | ||
JSON.toJSONString(new Response<>(new A())); | ||
} | ||
} | ||
|
||
@RepeatedTest(100) | ||
void testList() { | ||
for (int i = 0; i < 1000; i++) { | ||
// Collections.singletonList(0)改成0也会异常,异常概率小一些 | ||
JSON.toJSONString(new Response<>(Collections.singletonList(0))); | ||
} | ||
} | ||
} |