diff --git a/src/main/java/hudson/remoting/Engine.java b/src/main/java/hudson/remoting/Engine.java index 799a896af..363cb19b2 100644 --- a/src/main/java/hudson/remoting/Engine.java +++ b/src/main/java/hudson/remoting/Engine.java @@ -553,7 +553,8 @@ public void afterResponse(HandshakeResponse hr) { } } HeaderHandler headerHandler = new HeaderHandler(); - ContainerProvider.getWebSocketContainer().connectToServer(new Endpoint() { + @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "just trust me here") + class AgentEndpoint extends Endpoint { AbstractByteArrayCommandTransport.ByteArrayReceiver receiver; @Override public void onOpen(Session session, EndpointConfig config) { @@ -565,7 +566,6 @@ public void onOpen(Session session, EndpointConfig config) { events.error(x); } } - @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "just trust me here") private void onMessage(byte[] message) { LOGGER.finest(() -> "received message of length " + message.length); receiver.handle(message); @@ -610,7 +610,9 @@ public void closeRead() throws IOException { session.close(); } } - }, ClientEndpointConfig.Builder.create().configurator(headerHandler).build(), URI.create(candidateUrls.get(0).toString().replaceFirst("^http", "ws") + "wsagents/")); + } + ContainerProvider.getWebSocketContainer().connectToServer(new AgentEndpoint(), + ClientEndpointConfig.Builder.create().configurator(headerHandler).build(), URI.create(candidateUrls.get(0).toString().replaceFirst("^http", "ws") + "wsagents/")); while (ch.get() == null) { Thread.sleep(100); }