diff --git a/core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplList.java b/core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplList.java index 97d4c46039..78776618ce 100644 --- a/core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplList.java +++ b/core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplList.java @@ -174,6 +174,7 @@ public static ObjectReader of(Type type, Class listClass, long features) { instanceClass = TreeSet.class; builder = (Function) Collections::synchronizedNavigableSet; break; + case "java.util.RandomAccessSubList": case "java.util.AbstractList$RandomAccessSubList": instanceClass = ArrayList.class; break; diff --git a/core/src/test/java/com/alibaba/fastjson2/issues_2800/Issue2851.java b/core/src/test/java/com/alibaba/fastjson2/issues_2800/Issue2851.java index 2f57d2794c..c1fddcf23c 100644 --- a/core/src/test/java/com/alibaba/fastjson2/issues_2800/Issue2851.java +++ b/core/src/test/java/com/alibaba/fastjson2/issues_2800/Issue2851.java @@ -11,9 +11,10 @@ public class Issue2851 { @Test public void test() { + List list = Arrays.asList("").subList(0, 1); byte[] bytes = JSONB.toBytes(list, JSONWriter.Feature.WriteClassName); - JSONReader.AutoTypeBeforeHandler autoTypeFilter = JSONReader.autoTypeFilter("java.util.AbstractList"); + JSONReader.AutoTypeBeforeHandler autoTypeFilter = JSONReader.autoTypeFilter("java.util."); JSONReader.Context context = JSONFactory.createReadContext(); context.config(autoTypeFilter); List parsed = (List) JSONB.parse(bytes, context);