diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java index dee91e31471..7e32d0672bf 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java @@ -55,6 +55,8 @@ abstract public class WriteFlusher private final EndPoint _endPoint; private final AtomicReference _state = new AtomicReference<>(); + Throwable last; + static { // fill the state machine @@ -270,7 +272,13 @@ abstract public class WriteFlusher LOG.debug("write: {} {}", this, BufferUtil.toDetailString(buffers)); if (!updateState(__IDLE, __WRITING)) + { + if (last!=null) + last.printStackTrace(); throw new WritePendingException(); + } + + last = new Throwable(); try { diff --git a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java index 65090c4b59e..c983591acb7 100644 --- a/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java +++ b/jetty-websocket/javax-websocket-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/NetworkFuzzer.java @@ -45,7 +45,7 @@ import org.eclipse.jetty.websocket.core.internal.Generator; public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseable { private final LocalServer server; - private final RawWebSocketClient rawClient; + private final WebSocketCoreClient client; private final RawUpgradeRequest upgradeRequest; private final UnitGenerator generator; private final FrameCapture frameCapture; @@ -65,9 +65,9 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab { super(); this.server = server; - this.rawClient = new RawWebSocketClient(); + this.client = new WebSocketCoreClient(); CompletableFuture futureOnCapture = new CompletableFuture<>(); - this.upgradeRequest = new RawUpgradeRequest(rawClient, wsURI, futureOnCapture); + this.upgradeRequest = new RawUpgradeRequest(client, wsURI, futureOnCapture); if (requestHeaders != null) { HttpFields fields = this.upgradeRequest.getHeaders(); @@ -77,10 +77,10 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab fields.put(name, value); }); } - this.rawClient.start(); + this.client.start(); this.generator = new UnitGenerator(Behavior.CLIENT); - CompletableFuture futureHandler = this.rawClient.connect(upgradeRequest); + CompletableFuture futureHandler = this.client.connect(upgradeRequest); CompletableFuture futureCapture = futureHandler.thenCombine(futureOnCapture, (channel, capture) -> capture); this.frameCapture = futureCapture.get(10, TimeUnit.SECONDS); } @@ -102,7 +102,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab @Override public void close() throws Exception { - this.rawClient.stop(); + this.client.stop(); } @Override @@ -156,7 +156,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab { try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire()) { - frameCapture.channel.sendFrame(f, blocker, false); + frameCapture.session.sendFrame(f, blocker, false); } } } @@ -168,7 +168,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab { try (SharedBlockingCallback.Blocker blocker = sharedBlockingCallback.acquire()) { - frameCapture.channel.sendFrame(f, blocker, false); + frameCapture.session.sendFrame(f, blocker, false); } } } @@ -184,10 +184,6 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab } } - public static class RawWebSocketClient extends WebSocketCoreClient - { - } - public static class RawUpgradeRequest extends UpgradeRequest { private final CompletableFuture futureCapture; @@ -226,7 +222,7 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab private final BlockingQueue receivedFrames = new LinkedBlockingQueue<>(); private final EndPoint endPoint; private final SharedBlockingCallback blockingCallback = new SharedBlockingCallback(); - private CoreSession channel; + private CoreSession session; public FrameCapture(EndPoint endPoint) { @@ -247,20 +243,26 @@ public class NetworkFuzzer extends Fuzzer.Adapter implements Fuzzer, AutoCloseab public void onFrame(Frame frame, Callback callback) { receivedFrames.offer(Frame.copy(frame)); - callback.succeeded(); + synchronized(this) + { + callback.succeeded(); + } } @Override public void onOpen(CoreSession coreSession) throws Exception { - this.channel = coreSession; + this.session = coreSession; } public void writeRaw(ByteBuffer buffer) throws IOException { - try (SharedBlockingCallback.Blocker blocker = blockingCallback.acquire()) + synchronized (this) { - this.endPoint.write(blocker, buffer); + try (SharedBlockingCallback.Blocker blocker = blockingCallback.acquire()) + { + this.endPoint.write(blocker, buffer); + } } } }