harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r428617 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java test/java/tests/api/java/net/URLTest.java
Date Fri, 04 Aug 2006 04:44:27 GMT
Author: pyang
Date: Thu Aug  3 21:44:26 2006
New Revision: 428617

URL: http://svn.apache.org/viewvc?rev=428617&view=rev
Log:
Fix for HARMONY-1049 ([classlib][luni] java.net.URL.openConnection() throws unexpected AccessControlException
when security manager is enabled.)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java?rev=428617&r1=428616&r2=428617&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
Thu Aug  3 21:44:26 2006
@@ -41,6 +41,7 @@
 import java.net.UnknownServiceException;
 import java.security.AccessController;
 import java.security.Permission;
+import java.security.PrivilegedAction;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -516,7 +517,12 @@
         } catch (URISyntaxException e) {
             // do nothing.
         }
-        responseCache = ResponseCache.getDefault();
+        responseCache = AccessController
+                .doPrivileged(new PrivilegedAction<ResponseCache>() {
+                    public ResponseCache run() {
+                        return ResponseCache.getDefault();
+                    }
+                });
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java?rev=428617&r1=428616&r2=428617&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/URLTest.java
Thu Aug  3 21:44:26 2006
@@ -1161,6 +1161,22 @@
 		}
 	}
 
+    /**
+     * @tests java.net.URL#openConnection()
+     */
+    public void test_openConnection_Security() throws Exception {
+        // regression test for Harmony-1049
+        System.setSecurityManager(new SecurityManager());
+        try {
+            URL u = new URL("http://anyhost");
+            // openConnection should return successfully, and no exception
+            // should be thrown.
+            u.openConnection();
+        } finally {
+            System.setSecurityManager(null);
+        }
+    }
+    
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message