cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1213853 - in /cxf/branches/2.3.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
Date Tue, 13 Dec 2011 18:49:04 GMT
Author: dkulp
Date: Tue Dec 13 18:49:04 2011
New Revision: 1213853

URL: http://svn.apache.org/viewvc?rev=1213853&view=rev
Log:
Merged revisions 1213461 via svnmerge from 
https://svn.us.apache.org/repos/asf/cxf/branches/2.4.x-fixes

................
  r1213461 | dkulp | 2011-12-12 17:01:43 -0500 (Mon, 12 Dec 2011) | 10 lines
  
  Merged revisions 1213457 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1213457 | dkulp | 2011-12-12 16:56:43 -0500 (Mon, 12 Dec 2011) | 2 lines
    
    [CXF-3867] Add a couple methods for keeping the URLConnection
    defaultUsesCaches thing set to true.
  ........
................

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
    cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 13 18:49:04 2011
@@ -1,2 +1,2 @@
-/cxf/branches/2.4.x-fixes:1212512
+/cxf/branches/2.4.x-fixes:1212512,1213461
 /cxf/trunk:1212509

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java?rev=1213853&r1=1213852&r2=1213853&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
(original)
+++ cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java
Tue Dec 13 18:49:04 2011
@@ -19,14 +19,21 @@
 
 package org.apache.cxf.common.logging;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLConnection;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import javax.imageio.ImageIO;
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.apache.cxf.common.util.StringUtils;
+
 /**
  * This is called from LogUtils as LogUtils is almost always one of the VERY
  * first classes loaded in CXF so we can try and register to hacks/workarounds
@@ -44,6 +51,41 @@ final class JDKBugHacks {
         //not constructed
     }
     
+    private static boolean skipHack(final String key) {
+        String cname = null;
+        try {
+            cname = AccessController.doPrivileged(new PrivilegedAction<String>() {
+                public String run() {
+                    return System.getProperty(key);
+                }
+            });
+            if (StringUtils.isEmpty(cname)) {
+                InputStream ins = Thread.currentThread().getContextClassLoader()
+                    .getResourceAsStream("META-INF/cxf/" + key);
+                if (ins == null) {
+                    ins = ClassLoader.getSystemResourceAsStream("META-INF/cxf/" + key);
+                }
+                if (ins != null) {
+                    BufferedReader din = new BufferedReader(new InputStreamReader(ins));
+                    try {
+                        cname = din.readLine();
+                        if (cname != null) {
+                            cname.trim();
+                        }
+                    } finally {
+                        din.close();
+                    }
+                }
+            }
+        } catch (Throwable t) {
+            //ignore
+        }
+        if (cname == null) {
+            cname = "false";
+        }
+        return Boolean.parseBoolean(cname);
+    }
+    
     public static void doHacks() {
         try {
             ClassLoader orig = Thread.currentThread().getContextClassLoader();
@@ -64,14 +106,17 @@ final class JDKBugHacks {
                     // 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
-                    URL url = new URL("jar:file://dummy.jar!/");
-                    URLConnection uConn = new URLConnection(url) {
-                        @Override
-                        public void connect() throws IOException {
-                            // NOOP
-                        }
-                    };
-                    uConn.setDefaultUseCaches(false);
+                    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);
+                    }
                 } catch (Throwable e) {
                     //ignore
                 }

Modified: cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java?rev=1213853&r1=1213852&r2=1213853&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
Tue Dec 13 18:49:04 2011
@@ -24,6 +24,8 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -66,7 +68,17 @@ public final class LogUtils {
         JDKBugHacks.doHacks();
         
         try {
-            String cname = System.getProperty(KEY);
+            String cname = null;
+            try {
+                cname = AccessController.doPrivileged(new PrivilegedAction<String>()
{
+                    public String run() {
+                        return System.getProperty(KEY);
+                    }
+                });
+            } catch (Throwable t) {
+                //ignore - likely security exception or similar that won't allow
+                //access to the system properties.   We'll continue with other methods
+            }
             if (StringUtils.isEmpty(cname)) {
                 InputStream ins = Thread.currentThread().getContextClassLoader()
                     .getResourceAsStream("META-INF/cxf/" + KEY);



Mime
View raw message