Author: dkulp
Date: Fri May 25 14:50:34 2012
New Revision: 1342657

URL: http://svn.apache.org/viewvc?rev=1342657&view=rev
Log:
[CXF-4313] Add ability to completely turn off all the JDK hacks

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

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=1342657&r1=1342656&r2=1342657&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 
Fri May 25 14:50:34 2012
@@ -89,13 +89,15 @@ final class JDKBugHacks {
     }
     
     public static void doHacks() {
+        if (skipHack("org.apache.cxf.JDKBugHacks.all")) {
+            return;
+        }                
         try {
             // Use the system classloader as the victim for all this
             // ClassLoader pinning we're about to do.
             ClassLoaderHolder orig = ClassLoaderUtils
                 
.setThreadContextClassloader(ClassLoader.getSystemClassLoader());
             try {
-                
                 try {
                     //Trigger a call to sun.awt.AppContext.getAppContext()
                     if (!skipHack("org.apache.cxf.JDKBugHacks.imageIO")) {
@@ -122,9 +124,14 @@ final class JDKBugHacks {
                 try {
                     if 
(!skipHack("org.apache.cxf.JDKBugHacks.gcRequestLatency")) {
                         Class<?> clazz = Class.forName("sun.misc.GC");
-                        Method method = 
clazz.getDeclaredMethod("requestLatency",
+                        Method method = 
clazz.getDeclaredMethod("currentLatencyTarget");
+                        Long l = (Long)method.invoke(null);
+                        if (l != null && l.longValue() == 0) {
+                            //something already set it, move on
+                            method = clazz.getDeclaredMethod("requestLatency",
                                 new Class[] {Long.TYPE});
-                        method.invoke(null, Long.valueOf(36000000));
+                            method.invoke(null, Long.valueOf(36000000));
+                        }
                     }                    
                 } catch (Throwable e) {
                     //ignore

Modified: cxf/trunk/parent/pom.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1342657&r1=1342656&r2=1342657&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Fri May 25 14:50:34 2012
@@ -385,6 +385,7 @@
                         <systemPropertyVariables>
                             <java.io.tmpdir>${basedir}/target</java.io.tmpdir>
                             
<cxf.useRandomFirstPort>true</cxf.useRandomFirstPort>
+                            
<org.apache.cxf.JDKBugHacks.all>true</org.apache.cxf.JDKBugHacks.all>
                             
<org.apache.ws.commons.schema.protectReadOnlyCollections>${cxf.protect-xmlschema-collections}</org.apache.ws.commons.schema.protectReadOnlyCollections>
                             
<cxf.validateServiceSchemas>${cxf.validateServices}</cxf.validateServiceSchemas>
                             
<java.awt.headless>${java.awt.headless}</java.awt.headless>


Reply via email to