You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/05/24 20:30:21 UTC
svn commit: r1342366 -
/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
Author: dkulp
Date: Thu May 24 18:30:21 2012
New Revision: 1342366
URL: http://svn.apache.org/viewvc?rev=1342366&view=rev
Log:
Merged revisions 1342039 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1342039 | dkulp | 2012-05-23 16:37:41 -0400 (Wed, 23 May 2012) | 2 lines
[CXF-4313] Allow more options to disable various hacks
........
Modified:
cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java?rev=1342366&r1=1342365&r2=1342366&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java (original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java Thu May 24 18:30:21 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();