Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316449

Summary: NullPointerException when Outbound disconnect() called
Product: [RT] Jetty Reporter: Jeremy Stone <jeremy.stone>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox, mgorovoy
Version: unspecified   
Target Milestone: 7.0.2.RC0   
Hardware: All   
OS: All   
Whiteboard:

Description Jeremy Stone CLA 2010-06-10 07:57:56 EDT
Build Identifier: 7.1.3.v20100526

Calling disconnect() on a Websocket.Outbound instance causes NPE when an attempt is made to flush a null buffer. 

Here are the top few lines of the stack trace...
java.lang.NullPointerException
	at org.eclipse.jetty.websocket.WebSocketGenerator.expelBuffer(WebSocketGenerator.java:138)
	at org.eclipse.jetty.websocket.WebSocketGenerator.flush(WebSocketGenerator.java:110)
	at org.eclipse.jetty.websocket.WebSocketConnection.disconnect(WebSocketConnection.java:191)
	at ...

Simply changing WebSocketGenerator.flush(long) to the following may be enough to fix it:

    public synchronized int flush(long blockFor) throws IOException
    {
        if (_buffer==null)
            return 0;
        
        return expelBuffer(blockFor);
    }

Reproducible: Always
Comment 1 Greg Wilkins CLA 2010-06-11 00:03:26 EDT
fixed in r1996.

thanks for the report.
Comment 2 Greg Wilkins CLA 2010-06-11 03:13:56 EDT
fixed in r1996.

thanks for the report.