< prev index next >

src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java

Print this page
*** 63,15 ***
          this.sc = sc;
      }
  
      @SuppressWarnings("removal")
      static Socket create(SocketChannelImpl sc) {
-         PrivilegedExceptionAction<Socket> pa = () -> new SocketAdaptor(sc);
          try {
!             return AccessController.doPrivileged(pa);
!         } catch (PrivilegedActionException pae) {
!             throw new InternalError("Should not reach here", pae);
          }
      }
  
      private InetSocketAddress localAddress() {
          return (InetSocketAddress) sc.localAddress();
--- 63,19 ---
          this.sc = sc;
      }
  
      @SuppressWarnings("removal")
      static Socket create(SocketChannelImpl sc) {
          try {
!             if (System.getSecurityManager() == null) {
!                 return new SocketAdaptor(sc);
!             } else {
+                 PrivilegedExceptionAction<Socket> pa = () -> new SocketAdaptor(sc);
+                 return AccessController.doPrivileged(pa);
+             }
+         } catch (SocketException | PrivilegedActionException e) {
+             throw new InternalError(e);
          }
      }
  
      private InetSocketAddress localAddress() {
          return (InetSocketAddress) sc.localAddress();
< prev index next >