--- a/src/java.base/share/classes/java/net/Socket.java Sat Mar 02 11:44:38 2019 +0000
+++ b/src/java.base/share/classes/java/net/Socket.java Mon Mar 04 08:13:31 2019 +0000
@@ -161,11 +161,13 @@
impl.setSocket(this);
} else {
if (p == Proxy.NO_PROXY) {
+ SocketImplFactory factory = Socket.factory;
if (factory == null) {
impl = SocketImpl.createPlatformSocketImpl(false);
- impl.setSocket(this);
- } else
- setImpl();
+ } else {
+ impl = factory.createSocketImpl();
+ }
+ impl.setSocket(this);
} else
throw new IllegalArgumentException("Invalid Proxy");
}
@@ -529,6 +531,7 @@
* @since 1.4
*/
void setImpl() {
+ SocketImplFactory factory = Socket.factory;
if (factory != null) {
impl = factory.createSocketImpl();
checkOldImpl();
@@ -1731,7 +1734,7 @@
/**
* The factory for all client sockets.
*/
- private static SocketImplFactory factory = null;
+ private static volatile SocketImplFactory factory;
/**
* Sets the client socket implementation factory for the