| Summary: | WebSocket connections should be closed when application context is stopped | ||
|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | Simone Bordet <simone.bordet> |
| Component: | websocket | Assignee: | Simone Bordet <simone.bordet> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | jetty-inbox |
| Version: | 7.6.0.RC0 | ||
| Target Milestone: | 7.5.x | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
|
Description
Simone Bordet
Fixed by making WebSocketFactory extends AbstractLifeCycle, and tracking WebSocketServletConnections. When WebSocketFactory is stopped, connections are closed with code 1001 (close_shutdown). The same has been made for WebSocketClientFactory: connections are now tracked and when it's stopped, connections are closed with code 1001. In both cases, connections are tracked using a ConcurrentLinkedQueue. Addition to the queue is done before invoking application callbacks such as onOpen(), and only if the factory is running. Removal from the queue piggybacks on the Connection.onClose() callback, that is invoked by the I/O layer when a connection is closed. When the factory is being stopped, no additions are possible, and only removals or iteration over connections may be concurrent. Closing a connection that is already closed is a no-op, so we're safe. |