I've been working with OJB configured with Tomcat using the Java Security Manager and have run into a piece of code that requires the use of the doPrivileged API but is missing.
In the file: /org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java , the following method uses the doPrivileged API at the top of the function but the code in the finally block also needs to be marked as privileged code. The attached file is a cvs diff that wraps the code in the finally block using an anonymous inner class.
public synchronized Object get(Object obj) throws MetadataException
{
boolean before = getField().isAccessible();
AccessController.doPrivileged(setAccessibleAction);
... try
{
...
}
catch(...)
{
...
}
finally
{
field.setAccessible(before);
}
}Thanks.
Chris Giordano [EMAIL PROTECTED]
Index: PersistentFieldDefaultImpl.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java,v
retrieving revision 1.16
diff -r1.16 PersistentFieldDefaultImpl.java
209c209,217
< field.setAccessible(before);
---
> final boolean fbefore = before;
> AccessController.doPrivileged( new PrivilegedAction()
> {
> public Object run()
> {
> field.setAccessible(fbefore);
> return null;
> }
> });--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
