< prev index next >
src/java.base/share/classes/sun/nio/ch/ServerSocketAdaptor.java
Print this page
rev 52995 : 8223326: Regression introduced by CPU sync: java.security.AccessControlException: access denied ("java.net.NetPermission" "setSocketImpl")
Reviewed-by: dfuchs, alanb
Contributed-by: Alan Bateman <alan.bateman@oracle.com>
*** 36,46 ****
import java.net.StandardSocketOptions;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.NotYetBoundException;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
!
// Make a server-socket channel look like a server socket.
//
// The methods in this class are defined in exactly the same order as in
// java.net.ServerSocket so as to simplify tracking future changes to that
--- 36,48 ----
import java.net.StandardSocketOptions;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.NotYetBoundException;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
! import java.security.AccessController;
! import java.security.PrivilegedActionException;
! import java.security.PrivilegedExceptionAction;
// Make a server-socket channel look like a server socket.
//
// The methods in this class are defined in exactly the same order as in
// java.net.ServerSocket so as to simplify tracking future changes to that
*** 55,68 ****
// Timeout "option" value for accepts
private volatile int timeout;
public static ServerSocket create(ServerSocketChannelImpl ssc) {
try {
! return new ServerSocketAdaptor(ssc);
! } catch (IOException x) {
! throw new Error(x);
}
}
// ## super will create a useless impl
private ServerSocketAdaptor(ServerSocketChannelImpl ssc) throws IOException {
--- 57,71 ----
// Timeout "option" value for accepts
private volatile int timeout;
public static ServerSocket create(ServerSocketChannelImpl ssc) {
+ PrivilegedExceptionAction<ServerSocket> pa = () -> new ServerSocketAdaptor(ssc);
try {
! return AccessController.doPrivileged(pa);
! } catch (PrivilegedActionException pae) {
! throw new InternalError("Should not reach here", pae);
}
}
// ## super will create a useless impl
private ServerSocketAdaptor(ServerSocketChannelImpl ssc) throws IOException {
< prev index next >