src/java.base/share/classes/java/net/ServerSocket.java
branchniosocketimpl-branch
changeset 57175 7eb6cdd1204a
parent 57174 899641440751
child 57176 726630bc6a4c
equal deleted inserted replaced
57174:899641440751 57175:7eb6cdd1204a
   564             s.setImpl(si);
   564             s.setImpl(si);
   565             s.postAccept();
   565             s.postAccept();
   566             return;
   566             return;
   567         }
   567         }
   568 
   568 
   569         if (si instanceof DelegatingSocketImpl)
   569         // Socket has a SOCKS or HTTP SocketImpl
       
   570         if (si instanceof DelegatingSocketImpl) {
   570             si = ((DelegatingSocketImpl) si).delegate();
   571             si = ((DelegatingSocketImpl) si).delegate();
       
   572             assert si instanceof TrustedSocketImpl;
       
   573         }
   571 
   574 
   572         // ServerSocket or Socket is using a trusted SocketImpl
   575         // ServerSocket or Socket is using a trusted SocketImpl
   573         if (impl instanceof TrustedSocketImpl || si instanceof TrustedSocketImpl) {
   576         if (impl instanceof TrustedSocketImpl || si instanceof TrustedSocketImpl) {
   574             // accept connection with new SocketImpl
   577             // accept connection with new SocketImpl
   575             var nsi = (impl instanceof TrustedSocketImpl)
   578             var nsi = (impl instanceof TrustedSocketImpl)
   576                     ? ((TrustedSocketImpl) impl).newInstance(false)
   579                     ? ((TrustedSocketImpl) impl).newInstance(false)
   577                     : ((TrustedSocketImpl) si).newInstance(false);
   580                     : ((TrustedSocketImpl) si).newInstance(false);
   578             impl.accept(nsi);
   581             impl.accept(nsi);
   579             securityCheckAccept(nsi);  // closes nsi if permission check fails
   582             try {
       
   583                 // a custom impl has accepted the connection with a trusted SocketImpl
       
   584                 if (!(impl instanceof TrustedSocketImpl)) {
       
   585                     nsi.postCustomAccept();
       
   586                 }
       
   587             } finally {
       
   588                 securityCheckAccept(nsi);  // closes nsi if permission check fails
       
   589             }
   580 
   590 
   581             // copy state to the existing SocketImpl and update socket state
   591             // copy state to the existing SocketImpl and update socket state
   582             nsi.copyTo(si);
   592             nsi.copyTo(si);
   583             s.postAccept();
   593             s.postAccept();
   584             return;
   594             return;