Skip to content

Commit 4e208e1

Browse files
committed
Update release notes wrt #1823
1 parent 8d6c35d commit 4e208e1

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

release-notes/CREDITS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,3 +717,8 @@ Vincent Demay (vdemay@github)
717717
* Reported #1793: `java.lang.NullPointerException` in `ObjectArraySerializer.acceptJsonFormatVisitor()`
718718
for array value with `@JsonValue`
719719
(2.9.2)
720+
721+
Peter Jurkovic (peterjurkovic@github)
722+
* Reported #1823: ClassNameIdResolver doesn't handle resolve Collections$SingletonMap,
723+
Collections$SingletonSet
724+
(2.9.3)

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Project: jackson-databind
1313
(reported byb henryptung@github)
1414
#1807: Jackson-databind caches plain map deserializer and use it even map has `@JsonDeserializer`
1515
(reported by lexas2509@github)
16+
#1823: ClassNameIdResolver doesn't handle resolve Collections$SingletonMap & Collections$SingletonSet
17+
(reported by Peter J)
1618
#1842: `null` String for `Exception`s deserialized as String "null" instead of `null`
1719
(reported by ZeleniJure@github)
1820
#1843: Include name of unsettable property in exception from `SetterlessProperty.set()`

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolver.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected String _idFrom(Object value, Class<?> cls, TypeFactory typeFactory)
7070
}
7171
}
7272
String str = cls.getName();
73-
if (str.startsWith("java.util")) {
73+
if (str.startsWith("java.util.")) {
7474
// 25-Jan-2009, tatu: There are some internal classes that we cannot access as is.
7575
// We need better mechanism; for now this has to do...
7676

@@ -87,22 +87,20 @@ protected String _idFrom(Object value, Class<?> cls, TypeFactory typeFactory)
8787
// not optimal: but EnumMap is not a customizable type so this is sort of ok
8888
str = typeFactory.constructMapType(EnumMap.class, enumClass, valueClass).toCanonical();
8989
} else {
90-
/* 17-Feb-2010, tatus: Another such case: result of
91-
* Arrays.asList() is named like so in Sun JDK...
92-
* Let's just plain old ArrayList in its place
93-
* NOTE: chances are there are plenty of similar cases
94-
* for other wrappers... (immutable, singleton, synced etc)
95-
*/
96-
if (isJavaUtilCollectionClass(str, "List")) {
97-
str = "java.util.ArrayList";
98-
}else if(isJavaUtilCollectionClass(str, "Map")){
99-
str = "java.util.HashMap";
100-
}else if(isJavaUtilCollectionClass(str, "Set")){
101-
str = "java.util.HashSet";
90+
// 17-Feb-2010, tatus: Another such case: result of Arrays.asList() is
91+
// named like so in Sun JDK... Let's just plain old ArrayList in its place.
92+
// ... also, other similar cases exist...
93+
String suffix = str.substring(10);
94+
if (isJavaUtilCollectionClass(suffix, "List")) {
95+
str = ArrayList.class.getName();
96+
} else if(isJavaUtilCollectionClass(suffix, "Map")){
97+
str = HashMap.class.getName();
98+
} else if(isJavaUtilCollectionClass(suffix, "Set")){
99+
str = HashSet.class.getName();
102100
}
103101
}
104102
} else if (str.indexOf('$') >= 0) {
105-
/* Other special handling may be needed for inner classes, [JACKSON-584].
103+
/* Other special handling may be needed for inner classes,
106104
* The best way to handle would be to find 'hidden' constructor; pass parent
107105
* value etc (which is actually done for non-anonymous static classes!),
108106
* but that is just not possible due to various things. So, we will instead
@@ -131,8 +129,8 @@ public String getDescForKnownTypeIds() {
131129
return "class name used as type id";
132130
}
133131

134-
private static boolean isJavaUtilCollectionClass(String clazzName, String type){
135-
String end = clazzName.substring(9);
136-
return (end.startsWith(".Collections$") || end.startsWith(".Arrays$")) && clazzName.indexOf(type) > 0;
132+
private static boolean isJavaUtilCollectionClass(String clz, String type){
133+
return (clz.startsWith("Collections$") || clz.startsWith("Arrays$"))
134+
&& clz.indexOf(type) > 0;
137135
}
138136
}

src/test/java/com/fasterxml/jackson/databind/jsontype/impl/ClassNameIdResolverTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020

2121
@RunWith(PowerMockRunner.class)
2222
@PrepareForTest(TypeFactory.class)
23-
public class ClassNameIdResolverTest {
24-
23+
public class ClassNameIdResolverTest
24+
{
2525
@Mock
2626
private JavaType javaType;
2727

2828
@Mock
2929
private TypeFactory typeFactory;
30-
31-
30+
3231
private ClassNameIdResolver classNameIdResolver;
3332

3433
@Before

0 commit comments

Comments
 (0)