harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r981394 - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/n...
Date Mon, 02 Aug 2010 07:44:43 GMT
Author: hindessm
Date: Mon Aug  2 07:44:42 2010
New Revision: 981394

URL: http://svn.apache.org/viewvc?rev=981394&view=rev
Log:
Merge change from /harmony/enhanced/java/trunk@981356:

  r981356 | regisxu | 2010-08-02 03:56:43 +0100 (Mon, 02 Aug 2010) | 1 line
  
  Fix for HARMONY-6475: [classlib][nio] - Selector.open() throw AccessControlException when
SecurityManager is installed


Modified:
    harmony/enhanced/java/branches/java6/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/depends/libs/   (props changed)
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
    harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
    harmony/enhanced/java/branches/java6/drlvm/   (props changed)
    harmony/enhanced/java/branches/java6/jdktools/   (props changed)

Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  2 07:44:42 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632
+/harmony/enhanced/java/trunk:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632,981356
 /harmony/enhanced/trunk:476395-929252
 /incubator/harmony/enhanced/trunk:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  2 07:44:42 2010
@@ -1,7 +1,7 @@
 /harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
 /harmony/enhanced/classlib/trunk/working_classlib:884014-884286
 /harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632
+/harmony/enhanced/java/trunk/classlib:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632,981356
 /harmony/enhanced/trunk/classlib:476395-929252
 /harmony/enhanced/trunk/working_classlib:476396-920147
 /incubator/harmony/enhanced/trunk/classlib:292550-476394

Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  2 07:44:42 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632,981356
 /harmony/enhanced/trunk/classlib/depends/libs:476395-929252
 /incubator/harmony/enhanced/trunk/classlib/depends/libs:292550-476394

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java?rev=981394&r1=981393&r2=981394&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java
Mon Aug  2 07:44:42 2010
@@ -24,6 +24,10 @@ import java.nio.ByteBuffer;
 import java.nio.channels.Pipe;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.spi.SelectorProvider;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 import org.apache.harmony.luni.platform.FileDescriptorHandler;
 
@@ -42,21 +46,30 @@ final class PipeImpl extends Pipe {
 
     public PipeImpl() throws IOException {
         super();
+        sink = new SinkChannelImpl(SelectorProvider.provider());
+        source = new SourceChannelImpl(SelectorProvider.provider());
         try {
-            sink = new SinkChannelImpl(SelectorProvider.provider());
-            source = new SourceChannelImpl(SelectorProvider.provider());
-            sink.finishConnect();
-            source.accept();
-            source.closeServer();
-        } catch(IOException ioe){
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+                public Void run() throws Exception {
+                    sink.finishConnect();
+                    source.accept();
+                    source.closeServer();
+                    return null;
+                }
+            });
+        } catch (PrivilegedActionException e) {
             reset();
-            throw ioe;
-        } catch(RuntimeException e){
-            reset();
-            throw e;
+            Exception ex = e.getException();
+            if (ex instanceof IOException) {
+                throw (IOException) ex;
+            }
+            if (ex instanceof RuntimeException) {
+                throw (RuntimeException) ex;
+            }
+            throw new RuntimeException(ex);
         }
     }
-    
+
     private void reset(){
         if(sink != null){
             try {

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=981394&r1=981393&r2=981394&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
Mon Aug  2 07:44:42 2010
@@ -746,7 +746,7 @@ class SocketChannelImpl extends SocketCh
          */
         @Override
         public boolean isConnected() {
-            return channel.isConnected();
+            return super.isConnected() || channel.isConnected();
         }
 
         /**

Modified: harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java?rev=981394&r1=981393&r2=981394&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/PipeTest.java
Mon Aug  2 07:44:42 2010
@@ -17,9 +17,11 @@
 package org.apache.harmony.nio.tests.java.nio.channels;
 
 import java.io.IOException;
+import java.net.NetPermission;
 import java.nio.channels.Pipe;
 import java.nio.channels.Pipe.SinkChannel;
 import java.nio.channels.Pipe.SourceChannel;
+import java.security.Permission;
 
 import junit.framework.TestCase;
 
@@ -36,6 +38,22 @@ public class PipeTest extends TestCase {
 		assertNotNull(pipe);
 	}
 	
+    /**
+     * @tests java.nio.channels.Pipe#open()
+     */
+    public void test_open_securityManager() throws IOException {
+        SecurityManager old = System.getSecurityManager();
+        SecurityManager sm = new MockSM();
+
+        try {
+            System.setSecurityManager(sm);
+            Pipe pipe = Pipe.open();
+            assertNotNull(pipe);
+        } finally {
+            System.setSecurityManager(old);
+        }
+    }
+
 	/**
 	 * @tests java.nio.channels.Pipe#sink()
 	 */
@@ -55,3 +73,17 @@ public class PipeTest extends TestCase {
 	}
 
 }
+
+class MockSM extends SecurityManager {
+    public void checkPermission(Permission permission) {
+        if (permission instanceof NetPermission) {
+            throw new SecurityException();
+        }
+
+        if (permission instanceof RuntimePermission) {
+            if ("setSecurityManager".equals(permission.getName())) {
+                return;
+            }
+        }
+    }
+}

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  2 07:44:42 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632
+/harmony/enhanced/java/trunk/drlvm:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632,981356
 /harmony/enhanced/trunk/drlvm:476395-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/drlvm:292550-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  2 07:44:42 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632
+/harmony/enhanced/java/trunk/jdktools:929253-979569,979593,979613,979615,979647,979659,979682,979897,980326,980632,981356
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message