Mantis - Resin
Viewing Issue Advanced Details
5837 minor random 12-08-14 02:29 03-01-15 10:47
samadams  
ferg  
normal  
closed 4.0.41  
fixed  
none    
none 4.0.44  
0005837: NullPointerException when closing WebSocketPrintWriter
I've seen the following exception when calling close() on WebSocketPrintWriter:

Exception in thread "pool-166-thread-48" java.lang.NullPointerException
at com.caucho.remote.websocket.WebSocketWriter.complete(WebSocketWriter.java:251)
at com.caucho.remote.websocket.WebSocketWriter.close(WebSocketWriter.java:200)
at com.caucho.remote.websocket.WebSocketPrintWriter.close(WebSocketPrintWriter.java:56)

Code snippet:

    public void publishMessage(final WebSocketContext context, final String message) throws IOException {

        PrintWriter writer = null;
        try {
            writer = context.startTextMessage();
            writer.print(message);
        } finally {
            if (writer != null) {
                writer.close();
            }
        }
    }


There are no notes attached to this issue.