http-client-impl: use Reference.reachabilityFence to make clear the websokect BuilderImpl must stay strongly referenced until after the WebSocketImpl is created.
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java Wed Nov 08 16:39:47 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/websocket/WebSocketImpl.java Wed Nov 08 17:14:43 2017 +0000
@@ -26,6 +26,7 @@
package jdk.incubator.http.internal.websocket;
import java.io.IOException;
+import java.lang.ref.Reference;
import java.net.InetSocketAddress;
import java.net.ProtocolException;
import java.net.Proxy;
@@ -206,6 +207,11 @@
// returned from the buildAsync _after_ onOpen has been signalled.
// This means if onOpen is lengthy, it might cause some problems.
ws.signalOpen();
+ // make sure we don't release the builder until this lambda
+ // has been executed. The builder has a strong reference to
+ // the HttpClientFacade, and we want to keep that live until
+ // after the raw channel is created and passed to WebSocketImpl.
+ Reference.reachabilityFence(b);
return ws;
};
OpeningHandshake h;