@ SuppressWarnings ( "unchecked" ) private void handleRequest ( long requestId , Object request ) { HandlerHolder holder = handlers . get ( request . getClass ( ) ) ; if ( holder == null ) { connection . handleResponseError ( requestId , new ConnectException ( "no handler registered" ) ) ; return ; } Function < Object , CompletableFuture < Object > > handler = ( Function < Object , CompletableFuture < Object > > ) holder . handler ; try { holder . context . executor ( ) . execute ( ( ) -> { if ( open && connection . open ) { CompletableFuture < Object > responseFuture = handler . apply ( request ) ; if ( responseFuture != null ) { responseFuture . whenComplete ( ( response , error ) -> { if ( ! open || ! connection . open ) { connection . handleResponseError ( requestId , new ConnectException ( "connection closed" ) ) ; } else if ( error == null ) { connection . handleResponseOk ( requestId , response ) ; } else { connection . handleResponseError ( requestId , error ) ; } } ) ; } } else { connection . handleResponseError ( requestId , new ConnectException ( "connection closed" ) ) ; } } ) ; } catch ( RejectedExecutionException e ) { connection . handleResponseError ( requestId , new ConnectException ( "connection closed" ) ) ; } }
Receives a message .