Skip to content

Commit 522f2ba

Browse files
committed
Fix #1473
1 parent d338aa5 commit 522f2ba

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

release-notes/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Project: jackson-databind
1616
#1453: `UntypedObjectDeserializer` does not retain `float` type (over `double`)
1717
#1456: `TypeFactory` type resolution broken in 2.7 for generic types
1818
when using `constructType` with context
19+
#1473: Add explicit deserializer for `StringBuilder` due to Java 9 changes
1920

2021
2.8.5 (14-Nov-2016)
2122

src/main/java/com/fasterxml/jackson/databind/deser/std/FromStringDeserializer.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static Class<?>[] types() {
4141
TimeZone.class,
4242
InetAddress.class,
4343
InetSocketAddress.class,
44+
StringBuilder.class,
4445
};
4546
}
4647

@@ -85,6 +86,8 @@ public static Std findDeserializer(Class<?> rawType)
8586
kind = Std.STD_INET_ADDRESS;
8687
} else if (rawType == InetSocketAddress.class) {
8788
kind = Std.STD_INET_SOCKET_ADDRESS;
89+
} else if (rawType == StringBuilder.class) {
90+
kind = Std.STD_STRING_BUILDER;
8891
} else {
8992
return null;
9093
}
@@ -199,6 +202,7 @@ public static class Std extends FromStringDeserializer<Object>
199202
public final static int STD_TIME_ZONE = 10;
200203
public final static int STD_INET_ADDRESS = 11;
201204
public final static int STD_INET_SOCKET_ADDRESS = 12;
205+
public final static int STD_STRING_BUILDER = 13;
202206

203207
protected final int _kind;
204208

@@ -276,6 +280,8 @@ protected Object _deserialize(String value, DeserializationContext ctxt) throws
276280
}
277281
// host or unbracketed IPv6, without port number
278282
return new InetSocketAddress(value, 0);
283+
case STD_STRING_BUILDER:
284+
return new StringBuilder(value);
279285
}
280286
throw new IllegalArgumentException();
281287
}
@@ -290,10 +296,12 @@ protected Object _deserializeFromEmptyString() throws IOException {
290296
if (_kind == STD_LOCALE) {
291297
return Locale.ROOT;
292298
}
299+
if (_kind == STD_STRING_BUILDER) {
300+
return new StringBuilder();
301+
}
293302
return super._deserializeFromEmptyString();
294303
}
295304

296-
297305
protected int _firstHyphenOrUnderscore(String str)
298306
{
299307
for (int i = 0, end = str.length(); i < end; ++i) {

0 commit comments

Comments
 (0)