diff --git a/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy b/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy index 107eba47ab6..85fdc3fbd57 100644 --- a/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy +++ b/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy @@ -193,7 +193,12 @@ class DefaultMockServerWebSocketTest extends Specification { .addSubProtocol("v4.channel.k8s.io")) and: "A WebSocket listener" wsReq.onComplete { ws -> - future.complete(ws.result().headers().get("sec-websocket-protocol")) + if (ws.result() != null && ws.result().headers() != null) { + future.complete(ws.result().headers().get("sec-websocket-protocol")) + } + } + if (wsReq.result() != null && wsReq.result().headers() != null) { + future.complete(wsReq.result().headers().get("sec-websocket-protocol")) } and: "An instance of AsyncConditions" def async = new AsyncConditions(1)