-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ParameterizedTypeImpl memory leak case, fix #3329
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
38 changes: 38 additions & 0 deletions
38
src/test/java/com/alibaba/json/bvt/issue_3300/Issue3329.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,38 @@ | ||
package com.alibaba.json.bvt.issue_3300; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.parser.ParserConfig; | ||
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer; | ||
import com.alibaba.fastjson.util.IdentityHashMap; | ||
import com.alibaba.fastjson.util.ParameterizedTypeImpl; | ||
import junit.framework.TestCase; | ||
import java.util.List; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public class Issue3329 extends TestCase { | ||
public void test_for_issue() throws Exception { | ||
ParserConfig config = new ParserConfig(); | ||
IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers(); | ||
int initSize = deserializers.size(); | ||
for (int i = 0; i < 1000 * 10; ++i) { | ||
assertEquals(123, | ||
((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}", | ||
new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class), | ||
config | ||
)).value.id | ||
); | ||
} | ||
|
||
|
||
assertEquals(2, deserializers.size() - initSize); | ||
} | ||
|
||
public static class VO<T> { | ||
public T value; | ||
} | ||
|
||
public static class User { | ||
public int id; | ||
} | ||
} |