incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r1239279 - /incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java
Date Wed, 01 Feb 2012 19:23:47 GMT
Author: allee8285
Date: Wed Feb  1 19:23:46 2012
New Revision: 1239279

URL: http://svn.apache.org/viewvc?rev=1239279&view=rev
Log:
BVAL-100 Guard lang3.ClassUtil.getClass with doPriv()

Modified:
    incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java

Modified: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java?rev=1239279&r1=1239278&r2=1239279&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java
Wed Feb  1 19:23:46 2012
@@ -19,6 +19,7 @@ package org.apache.bval.jsr303.resolver;
 import java.lang.annotation.ElementType;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
 
 import javax.validation.Path;
 import javax.validation.TraversableResolver;
@@ -75,7 +76,7 @@ public class DefaultTraversableResolver 
     private void initJpa() {
         final ClassLoader classLoader = getClassLoader();
         try {
-            ClassUtils.getClass(classLoader, PERSISTENCE_UTIL_CLASSNAME, true);
+            getUtilClass(classLoader);
             log.debug("Found {} on classpath.", PERSISTENCE_UTIL_CLASSNAME);
         } catch (Exception e) {
             log.debug("Cannot find {} on classpath. All properties will per default be traversable.",
PERSISTENCE_UTIL_CLASSNAME);
@@ -102,8 +103,6 @@ public class DefaultTraversableResolver 
         return jpaTR != null && CachingTraversableResolver.needsCaching(jpaTR);
     }
 
-
-    
     private static ClassLoader getClassLoader()
     {
       return (System.getSecurityManager() == null)
@@ -121,5 +120,17 @@ public class DefaultTraversableResolver 
       return (loader != null) ? loader : ClassHelper.class.getClassLoader();
     }
 
+    private static Class<?> getUtilClass(final ClassLoader classLoader) throws Exception
{
+        return (System.getSecurityManager() == null) 
+            ? getUtilClass0(classLoader)
+            : AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
{
+                    public Class<?> run() throws Exception {
+                        return getUtilClass0(classLoader);
+                    }
+                });
+    }
 
+    private static Class<?> getUtilClass0(ClassLoader classLoader) throws Exception
{
+        return ClassUtils.getClass(classLoader, PERSISTENCE_UTIL_CLASSNAME, true);
+    }
 }



Mime
View raw message