HHH-10349 : PersistenceUtilHelper should call getDeclaredField/Method inside of privileged block
(cherry picked from commit 986b2b65ad
)
This commit is contained in:
parent
4acd4bff8e
commit
e150a6140e
|
@ -10,6 +10,8 @@ import java.io.Serializable;
|
|||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -352,7 +354,10 @@ public final class PersistenceUtilHelper {
|
|||
return attributeAccess;
|
||||
}
|
||||
|
||||
private AttributeAccess buildAttributeAccess(String attributeName) {
|
||||
private AttributeAccess buildAttributeAccess(final String attributeName) {
|
||||
final PrivilegedAction<AttributeAccess> action = new PrivilegedAction<AttributeAccess>() {
|
||||
@Override
|
||||
public AttributeAccess run() {
|
||||
for ( Class clazz : classHierarchy ) {
|
||||
try {
|
||||
final Field field = clazz.getDeclaredField( attributeName );
|
||||
|
@ -367,10 +372,12 @@ public final class PersistenceUtilHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//we could not find any match
|
||||
return new NoSuchAttributeAccess( specifiedClass, attributeName );
|
||||
}
|
||||
};
|
||||
return System.getSecurityManager() != null ? AccessController.doPrivileged( action ) : action.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue