Fixing end user callback failure if runtime exception occurs, renaming enque to enqueue

This commit is contained in:
Joakim Erdfelt 2012-12-19 10:05:25 -07:00
parent 2237053819
commit 0ef9b23724
2 changed files with 13 additions and 5 deletions

View File

@ -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();

View File

@ -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