Skip to content

Commit e237bca

Browse files
committed
Fix for issue with JSR-310 (java 8 date/time) module, TemporalAdjuster values
1 parent cb00c20 commit e237bca

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

release-notes/VERSION-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Project: jackson-databind
44
=== Releases ===
55
------------------------------------------------------------------------
66

7+
2.12.3 (not yet released)
8+
9+
- Fix for [modules-java8#207]: prevent fail on secondary Java 8 date/time types
10+
711
2.12.2 (03-Mar-2021)
812

913
#754: EXTERNAL_PROPERTY does not work well with `@JsonCreator` and

src/main/java/com/fasterxml/jackson/databind/util/BeanUtil.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,18 @@ public static String stdManglePropertyName(final String basename, final int offs
295295
* @since 2.12
296296
*/
297297
public static String checkUnsupportedType(JavaType type) {
298-
final Class<?> rawType = type.getRawClass();
298+
final String className = type.getRawClass().getName();
299299
String typeName, moduleName;
300300

301-
if (isJava8TimeClass(rawType)) {
301+
if (isJava8TimeClass(className)) {
302+
// [modules-java8#207]: do NOT check/block helper types in sub-packages,
303+
// but only main-level types (to avoid issues with module)
304+
if (className.indexOf('.', 10) >= 0) {
305+
return null;
306+
}
302307
typeName = "Java 8 date/time";
303308
moduleName = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310";
304-
} else if (isJodaTimeClass(rawType)) {
309+
} else if (isJodaTimeClass(className)) {
305310
typeName = "Joda date/time";
306311
moduleName = "com.fasterxml.jackson.datatype:jackson-datatype-joda";
307312
} else {
@@ -310,18 +315,26 @@ public static String checkUnsupportedType(JavaType type) {
310315
return String.format("%s type %s not supported by default: add Module \"%s\" to enable handling",
311316
typeName, ClassUtil.getTypeDescription(type), moduleName);
312317
}
313-
318+
314319
/**
315320
* @since 2.12
316321
*/
317322
public static boolean isJava8TimeClass(Class<?> rawType) {
318-
return rawType.getName().startsWith("java.time.");
323+
return isJava8TimeClass(rawType.getName());
324+
}
325+
326+
private static boolean isJava8TimeClass(String className) {
327+
return className.startsWith("java.time.");
319328
}
320329

321330
/**
322331
* @since 2.12
323332
*/
324333
public static boolean isJodaTimeClass(Class<?> rawType) {
325-
return rawType.getName().startsWith("org.joda.time.");
334+
return isJodaTimeClass(rawType.getName());
335+
}
336+
337+
private static boolean isJodaTimeClass(String className) {
338+
return className.startsWith("org.joda.time.");
326339
}
327340
}

0 commit comments

Comments
 (0)