Skip to content

Commit 5597e8b

Browse files
jdconradbreskeby
authored andcommitted
update DefBootstrap to handle Error from ClassValue
1 parent dc14073 commit 5597e8b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

modules/lang-painless/src/main/java/org/elasticsearch/painless/DefBootstrap.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ protected MethodHandle computeValue(Class<?> receiverType) {
201201
try {
202202
return lookup(flavor, name, receiverType).asType(type);
203203
} catch (Throwable t) {
204+
// ClassValue.getFromHashMap wraps checked exceptions as Error, but
205+
// we do not want to crash here because we could not process the type
206+
// correctly as part of a script, so we instead unwrap the Error and
207+
// rethrow the original exception
208+
if (t instanceof Error && ((Error) t).getCause() instanceof Exception) {
209+
t = (Exception) ((Error) t).getCause();
210+
}
204211
Def.rethrow(t);
205212
throw new AssertionError();
206213
}

0 commit comments

Comments
 (0)