cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1342039 - /cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
Date Wed, 23 May 2012 20:37:41 GMT
Author: dkulp
Date: Wed May 23 20:37:41 2012
New Revision: 1342039

URL: http://svn.apache.org/viewvc?rev=1342039&view=rev
Log:
[CXF-4313] Allow more options to disable various hacks

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java?rev=1342039&r1=1342038&r2=1342039&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java Wed May 23
20:37:41 2012
@@ -98,34 +98,18 @@ final class JDKBugHacks {
                 
                 try {
                     //Trigger a call to sun.awt.AppContext.getAppContext()
-                    ImageIO.getCacheDirectory();
-                } catch (Throwable t) {
-                    //ignore
-                }
-                try {
-                    // Several components end up opening JarURLConnections without first
-                    // disabling caching. This effectively locks the file.
-                    // JAXB does this and thus affects us pretty badly.
-                    // Doesn't matter that this JAR doesn't exist - just as long as
-                    // the URL is well-formed
-                    boolean skip = skipHack("org.apache.cxf.JDKBugHacks.defaultUsesCaches");
-                    if (!skip) {
-                        URL url = new URL("jar:file://dummy.jar!/");
-                        URLConnection uConn = new URLConnection(url) {
-                            @Override
-                            public void connect() throws IOException {
-                                // NOOP
-                            }
-                        };
-                        uConn.setDefaultUseCaches(false);
+                    if (!skipHack("org.apache.cxf.JDKBugHacks.imageIO")) {
+                        ImageIO.getCacheDirectory();
                     }
-                } catch (Throwable e) {
+                } catch (Throwable t) {
                     //ignore
                 }
                 try {
                     //DocumentBuilderFactory seems to SOMETIMES pin the classloader
-                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                    factory.newDocumentBuilder();
+                    if (!skipHack("org.apache.cxf.JDKBugHacks.documentBuilderFactory")) {
+                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                        factory.newDocumentBuilder();
+                    }
                 } catch (Throwable e) {
                     //ignore
                 }
@@ -136,10 +120,12 @@ final class JDKBugHacks {
                 // eventual calls to requestLatency(long) are:
                 // - javax.management.remote.rmi.RMIConnectorServer.start()
                 try {
-                    Class<?> clazz = Class.forName("sun.misc.GC");
-                    Method method = clazz.getDeclaredMethod("requestLatency",
-                            new Class[] {Long.TYPE});
-                    method.invoke(null, Long.valueOf(3600000));
+                    if (!skipHack("org.apache.cxf.JDKBugHacks.gcRequestLatency")) {
+                        Class<?> clazz = Class.forName("sun.misc.GC");
+                        Method method = clazz.getDeclaredMethod("requestLatency",
+                                new Class[] {Long.TYPE});
+                        method.invoke(null, Long.valueOf(36000000));
+                    }                    
                 } catch (Throwable e) {
                     //ignore
                 }
@@ -148,18 +134,22 @@ final class JDKBugHacks {
                 // class loader.
                 try {
                     // Policy.getPolicy();
-                    Class<?> policyClass = Class
-                        .forName("javax.security.auth.Policy");
-                    Method method = policyClass.getMethod("getPolicy");
-                    method.invoke(null);
+                    if (!skipHack("org.apache.cxf.JDKBugHacks.policy")) {
+                        Class<?> policyClass = Class
+                            .forName("javax.security.auth.Policy");
+                        Method method = policyClass.getMethod("getPolicy");
+                        method.invoke(null);
+                    }
                 } catch (Throwable e) {
                     // ignore
                 }
                 try {
                     // Initializing javax.security.auth.login.Configuration retains a static
reference 
                     // to the context class loader.
-                    Class.forName("javax.security.auth.login.Configuration", true, 
-                                  ClassLoader.getSystemClassLoader());
+                    if (!skipHack("org.apache.cxf.JDKBugHacks.authConfiguration")) {
+                        Class.forName("javax.security.auth.login.Configuration", true, 
+                                      ClassLoader.getSystemClassLoader());
+                    }
                 } catch (Throwable e) {
                     // Ignore
                 }
@@ -167,7 +157,29 @@ final class JDKBugHacks {
                 // initializes the Java Cryptography Architecture. Under certain
                 // conditions this starts a Token poller thread with TCCL equal
                 // to the web application class loader.
-                java.security.Security.getProviders();
+                if (!skipHack("org.apache.cxf.JDKBugHacks.securityProviders")) {
+                    java.security.Security.getProviders();
+                }
+                
+                try {
+                    // Several components end up opening JarURLConnections without first
+                    // disabling caching. This effectively locks the file.
+                    // JAXB does this and thus affects us pretty badly.
+                    // Doesn't matter that this JAR doesn't exist - just as long as
+                    // the URL is well-formed
+                    if (!skipHack("org.apache.cxf.JDKBugHacks.defaultUsesCaches")) {
+                        URL url = new URL("jar:file://dummy.jar!/");
+                        URLConnection uConn = new URLConnection(url) {
+                            @Override
+                            public void connect() throws IOException {
+                                // NOOP
+                            }
+                        };
+                        uConn.setDefaultUseCaches(false);
+                    }
+                } catch (Throwable e) {
+                    //ignore
+                }                
             } finally {
                 if (orig != null) {
                     orig.reset();



Mime
View raw message