Skip to content

Commit

Permalink
LDEV-5118 - only log exception in case reflection does not fail
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Oct 25, 2024
1 parent 1673c36 commit e8a6b55
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,22 @@ public Object invoke() throws PageException, InstantiationException, IllegalAcce
}
catch (IncompatibleClassChangeError | ClassFormatError | IllegalStateException e) {
if (!Clazz.allowReflection()) throw e;
LogUtil.log("direct", e);
DynamicInvoker di = DynamicInvoker.getExistingInstance();
lucee.transformer.dynamic.meta.Constructor constr = Clazz.getConstructorMatch(di.getClazz(clazz, true), args, true);
return ((LegacyConstuctor) constr).getConstructor().newInstance(args);

// fallback to reflection
boolean failed = false;
try {
DynamicInvoker di = DynamicInvoker.getExistingInstance();
lucee.transformer.dynamic.meta.Constructor constr = Clazz.getConstructorMatch(di.getClazz(clazz, true), args, true);
return ((LegacyConstuctor) constr).getConstructor().newInstance(args);
}
catch (IncompatibleClassChangeError | ClassFormatError | IllegalStateException ex) {
failed = true;
throw e;
}
finally {
// we only log the exception from direct invocation, in case reflection does not fail
if (!failed) LogUtil.log("direct", e);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.2.0.132-SNAPSHOT"/>
<property name="version" value="6.2.0.133-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.2.0.132-SNAPSHOT</version>
<version>6.2.0.133-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit e8a6b55

Please sign in to comment.