public boolean handleExceptionFromServer(Writer writer,Reader reader,Throwable ex){
  if (ex instanceof ClosedChannelException) {
    if (_logger.isLoggable(Level.FINE))     _logger.log(Level.FINE,"Connection with client closed from [" + writer.getEndPointAddress() + "] endpoint.");
    return true;
  }
  if (ex instanceof MarshalContextClearedException) {
    if (_logger.isLoggable(Level.FINE))     _logger.log(Level.FINE,"Marshal context have been cleared, probably because the exported service class loader has been unloaded, service incoming invocation from [" + writer.getEndPointAddress() + "] endpoint.");
    return true;
  }
  try {
    String msg="LRMI Transport Protocol caught server exception caused by [" + writer.getEndPointAddress() + "] client.";
    if (ex instanceof LRMIUnhandledException) {
      if (_logger.isLoggable(Level.FINE))       _logger.log(Level.FINE,msg,ex);
      LRMIUnhandledException lrmiue=(LRMIUnhandledException)ex;
      if (lrmiue.getStage() == Stage.DESERIALIZATION) {
        reader.resetContext();
      }
      if (writer.isOpen())       writer.writeReply(new ReplyPacket(null,lrmiue));
      return false;
    }
 else     if (ex instanceof RuntimeException || ex instanceof InvalidClassException) {
      if (_logger.isLoggable(Level.SEVERE))       _logger.log(Level.SEVERE,msg,ex);
    }
 else     if (ex instanceof UnmarshalException) {
      if (_logger.isLoggable(Level.WARNING))       _logger.log(Level.WARNING,msg,ex);
    }
 else {
      if (_logger.isLoggable(Level.FINE))       _logger.log(Level.FINE,msg,ex);
    }
    if (writer.isOpen())     writer.writeReply(new ReplyPacket(null,new ProtocolException(msg,ex)));
    return true;
  }
 catch (  Exception ex2) {
    if (_logger.isLoggable(Level.FINE))     _logger.log(Level.FINE,"Failed to send handledServerException to endpoint [" + writer.getEndPointAddress() + "] , the client disconnected from the server.",ex);
    return true;
  }
}

public boolean handleExceptionFromServer ( Writer writer , Reader reader , Throwable ex ) { if ( ex instanceof ClosedChannelException ) { if ( _logger . isLoggable ( Level . FINE ) ) _logger . log ( Level . FINE , "Connection with client closed from [" + writer . getEndPointAddress ( ) + "] endpoint." ) ; return true ; } if ( ex instanceof MarshalContextClearedException ) { if ( _logger . isLoggable ( Level . FINE ) ) _logger . log ( Level . FINE , "Marshal context have been cleared, probably because the exported service class loader has been unloaded, service incoming invocation from [" + writer . getEndPointAddress ( ) + "] endpoint." ) ; return true ; } try { String msg = "LRMI Transport Protocol caught server exception caused by [" + writer . getEndPointAddress ( ) + "] client." ; if ( ex instanceof LRMIUnhandledException ) { if ( _logger . isLoggable ( Level . FINE ) ) _logger . log ( Level . FINE , msg , ex ) ; LRMIUnhandledException lrmiue = ( LRMIUnhandledException ) ex ; if ( lrmiue . getStage ( ) == Stage . DESERIALIZATION ) { reader . resetContext ( ) ; } if ( writer . isOpen ( ) ) writer . writeReply ( new ReplyPacket ( null , lrmiue ) ) ; return false ; } else if ( ex instanceof RuntimeException || ex instanceof InvalidClassException ) { if ( _logger . isLoggable ( Level . SEVERE ) ) _logger . log ( Level . SEVERE , msg , ex ) ; } else if ( ex instanceof UnmarshalException ) { if ( _logger . isLoggable ( Level . WARNING ) ) _logger . log ( Level . WARNING , msg , ex ) ; } else { if ( _logger . isLoggable ( Level . FINE ) ) _logger . log ( Level . FINE , msg , ex ) ; } if ( writer . isOpen ( ) ) writer . writeReply ( new ReplyPacket ( null , new ProtocolException ( msg , ex ) ) ) ; return true ; } catch ( Exception ex2 ) { if ( _logger . isLoggable ( Level . FINE ) ) _logger . log ( Level . FINE , "Failed to send handledServerException to endpoint [" + writer . getEndPointAddress ( ) + "] , the client disconnected from the server." , ex ) ; return true ; } }
send if possible the catch server exception to the client
