From 0ef9b23724c8add8e7250b222cbe1306e66a8b75 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 19 Dec 2012 10:05:25 -0700 Subject: [PATCH] Fixing end user callback failure if runtime exception occurs, renaming enque to enqueue --- .../common/io/AbstractWebSocketConnection.java | 2 +- .../websocket/common/io/WriteBytesProvider.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java index 5a64a45a1ac..7d9fdfdd36a 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java @@ -432,7 +432,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp synchronized (writeBytes) { - writeBytes.enque(frame,WriteCallbackWrapper.wrap(callback)); + writeBytes.enqueue(frame,WriteCallbackWrapper.wrap(callback)); } flush(); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java index e14ba5dee89..0681e3d4d85 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java @@ -97,10 +97,10 @@ public class WriteBytesProvider implements Callback this.closed = new AtomicBoolean(false); } - public void enque(Frame frame, Callback callback) + public void enqueue(Frame frame, Callback callback) { Objects.requireNonNull(frame); - LOG.debug("enque({}, {})",frame,callback); + LOG.debug("enqueue({}, {})",frame,callback); synchronized (this) { if (closed.get()) @@ -283,8 +283,16 @@ public class WriteBytesProvider implements Callback // All done with active FrameEntry if (active.callback != null) { - // notify of success - active.callback.succeeded(); + try + { + // TODO: should probably have callback invoked in new thread as part of scheduler + // notify of success + active.callback.succeeded(); + } + catch (Throwable t) + { + LOG.warn("Callback failure",t); + } } // null it out