Skip to content

Commit 6caa16d

Browse files
committed
HV-1439 Disable AnnotationProxy equals optimization if the security manager is enabled
Apparently, the security check for getInvocationHandler() was not correctly implemented in JDK 8 < 131.
1 parent 6be0928 commit 6caa16d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

engine/src/main/java/org/hibernate/validator/internal/util/annotationfactory/AnnotationProxy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ else if ( m.getDefaultValue() != null ) {
183183
}
184184

185185
private Map<String, Object> getAnnotationValues(Annotation annotation) {
186-
if ( Proxy.isProxyClass( annotation.getClass() ) ) {
186+
// We only enable this optimization if the security manager is not enabled. Otherwise,
187+
// we would have to add every package containing constraints to the security policy.
188+
if ( Proxy.isProxyClass( annotation.getClass() ) && System.getSecurityManager() == null ) {
187189
InvocationHandler invocationHandler = Proxy.getInvocationHandler( annotation );
188190
if ( invocationHandler instanceof AnnotationProxy ) {
189191
return ( (AnnotationProxy) invocationHandler ).values;

0 commit comments

Comments
 (0)