Author: markt
Date: Sun Jan 16 20:51:32 2011
New Revision: 1059660
URL: http://svn.apache.org/viewvc?rev=1059660&view=rev
Log:
Fix FindBugs warnings
Modified:
tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
tomcat/trunk/res/findbugs/filter-post-7.0.x-fixes.xml
Modified: tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java?rev=1059660&r1=1059659&r2=1059660&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java Sun
Jan 16 20:51:32 2011
@@ -21,6 +21,8 @@ package org.apache.catalina.startup;
import java.io.File;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
@@ -54,10 +56,10 @@ public final class ClassLoaderFactory {
private static final Log log = LogFactory.getLog(ClassLoaderFactory.class);
- protected static final Integer IS_DIR = new Integer(0);
- protected static final Integer IS_JAR = new Integer(1);
- protected static final Integer IS_GLOB = new Integer(2);
- protected static final Integer IS_URL = new Integer(3);
+ protected static final Integer IS_DIR = Integer.valueOf(0);
+ protected static final Integer IS_JAR = Integer.valueOf(1);
+ protected static final Integer IS_GLOB = Integer.valueOf(2);
+ protected static final Integer IS_URL = Integer.valueOf(3);
// --------------------------------------------------------- Public Methods
@@ -79,7 +81,7 @@ public final class ClassLoaderFactory {
*/
public static ClassLoader createClassLoader(File unpacked[],
File packed[],
- ClassLoader parent)
+ final ClassLoader parent)
throws Exception {
if (log.isDebugEnabled())
@@ -124,14 +126,17 @@ public final class ClassLoaderFactory {
}
// Construct the class loader itself
- URL[] array = set.toArray(new URL[set.size()]);
- StandardClassLoader classLoader = null;
- if (parent == null)
- classLoader = new StandardClassLoader(array);
- else
- classLoader = new StandardClassLoader(array, parent);
- return (classLoader);
-
+ final URL[] array = set.toArray(new URL[set.size()]);
+ return AccessController.doPrivileged(
+ new PrivilegedAction<StandardClassLoader>() {
+ @Override
+ public StandardClassLoader run() {
+ if (parent == null)
+ return new StandardClassLoader(array);
+ else
+ return new StandardClassLoader(array, parent);
+ }
+ });
}
@@ -152,7 +157,7 @@ public final class ClassLoaderFactory {
*/
public static ClassLoader createClassLoader(String locations[],
Integer types[],
- ClassLoader parent)
+ final ClassLoader parent)
throws Exception {
if (log.isDebugEnabled())
@@ -216,18 +221,22 @@ public final class ClassLoaderFactory {
}
// Construct the class loader itself
- URL[] array = set.toArray(new URL[set.size()]);
+ final URL[] array = set.toArray(new URL[set.size()]);
if (log.isDebugEnabled())
for (int i = 0; i < array.length; i++) {
log.debug(" location " + i + " is " + array[i]);
}
- StandardClassLoader classLoader = null;
- if (parent == null)
- classLoader = new StandardClassLoader(array);
- else
- classLoader = new StandardClassLoader(array, parent);
- return (classLoader);
+ return AccessController.doPrivileged(
+ new PrivilegedAction<StandardClassLoader>() {
+ @Override
+ public StandardClassLoader run() {
+ if (parent == null)
+ return new StandardClassLoader(array);
+ else
+ return new StandardClassLoader(array, parent);
+ }
+ });
}
Modified: tomcat/trunk/res/findbugs/filter-post-7.0.x-fixes.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-post-7.0.x-fixes.xml?rev=1059660&r1=1059659&r2=1059660&view=diff
==============================================================================
--- tomcat/trunk/res/findbugs/filter-post-7.0.x-fixes.xml (original)
+++ tomcat/trunk/res/findbugs/filter-post-7.0.x-fixes.xml Sun Jan 16 20:51:32
2011
@@ -38,4 +38,10 @@
<Method name="writeObject" />
<Bug code="Se" />
</Match>
+ <!-- Refactor Integer constants to an enum -->
+ <Match>
+ <Class name="org.apache.catalina.startup.ClassLoaderFactory" />
+ <Method name="createClassLoader" />
+ <Bug code="RC" />
+ </Match>
</FindBugsFilter>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]