private boolean handleRpcException ( RpcException e , int attemptNumber ) throws IOException { boolean tryPrivilegedPort = e . getStatus ( ) . equals ( RejectStatus . AUTH_ERROR ) ; boolean networkError = e . getStatus ( ) . equals ( RpcStatus . NETWORK_ERROR ) ; boolean retry = ( tryPrivilegedPort || networkError ) && ( ( attemptNumber + 1 ) < MOUNT_MAX_RETRIES ) ; if ( ! retry ) { String messageStart = networkError ? "network" : "rpc" ; String msg = String . format ( "%s error, server: %s, export: %s, RPC error: %s" , messageStart , _server , _exportedPath , e . getMessage ( ) ) ; throw new MountException ( MountStatus . MNT3ERR_IO , msg , e ) ; } System . out . println ( "retry " + ( attemptNumber + 1 ) ) ; if ( tryPrivilegedPort ) { LOG . info ( "Next try will be with a privileged port." ) ; } return tryPrivilegedPort ; }
Decide whether to retry or throw an exception