synchronized void dispose ( ) { if ( ! isDisposed ( ) ) { // First wait for all data from the connection to be read. Then unregister the handle. // Otherwise, unregistering might cause the server to be stopped and all child connections // to be closed. if ( connection != null ) { try { connection . waitForClose ( ) ; } catch ( IOException ioe ) { // no-op. } } server . unregister ( this ) ; // Set state to LOST if not yet final. setState ( State . LOST , false ) ; this . disposed = true ; } }
Mark the handle as disposed and set it as LOST in case the current state is not final .