Skip to content

Commit 83d3ec2

Browse files
committed
Try to improve troubleshooting of #2807
1 parent d296ebb commit 83d3ec2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

release-notes/VERSION-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Project: jackson-databind
1111
#2944: `@JsonCreator` on constructor not compatible with `@JsonIdentityInfo`,
1212
`PropertyGenerator`
1313
(reported by Lucian H)
14+
- Add debug improvements wrt #2807 (`ClassUtil.getClassMethods()`)
1415

1516
2.11.3 (02-Oct-2020)
1617

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,18 +1160,30 @@ public static Method[] getClassMethods(Class<?> cls)
11601160
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
11611161
if (loader == null){
11621162
// Nope... this is going to end poorly
1163-
throw ex;
1163+
return _failGetClassMethods(cls, ex);
11641164
}
11651165
final Class<?> contextClass;
11661166
try {
11671167
contextClass = loader.loadClass(cls.getName());
11681168
} catch (ClassNotFoundException e) {
11691169
ex.addSuppressed(e);
1170-
throw ex;
1170+
return _failGetClassMethods(cls, ex);
11711171
}
11721172
return contextClass.getDeclaredMethods(); // Cross fingers
1173+
} catch (Throwable t) {
1174+
return _failGetClassMethods(cls, t);
11731175
}
11741176
}
1177+
1178+
// @since 2.11.4 (see [databind#2807])
1179+
private static Method[] _failGetClassMethods(Class<?> cls, Throwable rootCause)
1180+
throws IllegalArgumentException
1181+
{
1182+
throw new IllegalArgumentException(String.format(
1183+
"Failed on call to `getDeclaredMethods()` on class `%s`, problem: (%s) %s",
1184+
cls.getName(), rootCause.getClass().getName(), rootCause.getMessage()),
1185+
rootCause);
1186+
}
11751187

11761188
/**
11771189
* @since 2.7

0 commit comments

Comments
 (0)