Program: 13240
Project: 13240
Buggy source:
/** 
 * Handle ConnectorExceptions from ConnectorFacade invocations.  Maps each ConnectorException subtype to the appropriate   {@link ResourceException} for passing to {@code handleError}.  Optionally logs to activity log.
 * @param context the ServerContext from the original request
 * @param request the original request
 * @param exception the ConnectorException that was thrown by the facade
 * @param resourceId the resourceId being operated on
 * @param before the object value "before" the request
 * @param after the object value "after" the request
 * @param handler the ResultHandler on which to call handleError
 * @param connectorExceptionActivityLogger the ActivityLogger to use to log the exception
 */
private void handleConnectorException(ServerContext context,Request request,ConnectorException exception,String resourceId,JsonValue before,JsonValue after,ResultHandler<?> handler,ActivityLogger connectorExceptionActivityLogger){
  String message=MessageFormat.format("String_Node_Str",request.getRequestType(),exception.getClass().getSimpleName(),resourceId);
  try {
    throw exception;
  }
 catch (  AlreadyExistsException e) {
    message=MessageFormat.format("String_Node_Str",resourceId);
    handler.handleError(new ConflictException(message,exception));
  }
catch (  ConfigurationException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,exception));
  }
catch (  ConnectionBrokenException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  ConnectionFailedException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  ConnectorIOException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  OperationTimeoutException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  PasswordExpiredException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ForbiddenException(message,exception));
  }
catch (  InvalidPasswordException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(ResourceException.getException(UNAUTHORIZED_ERROR_CODE,message,exception));
  }
catch (  UnknownUidException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),request.getResourceName(),resourceId);
    handler.handleError(new NotFoundException(message,exception).setDetail(new JsonValue(new HashMap<String,Object>())));
  }
catch (  InvalidCredentialException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(ResourceException.getException(UNAUTHORIZED_ERROR_CODE,message,exception));
  }
catch (  PermissionDeniedException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ForbiddenException(message,exception));
  }
catch (  ConnectorSecurityException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,exception));
  }
catch (  InvalidAttributeValueException e) {
    message=MessageFormat.format("String_Node_Str" + "String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new BadRequestException(message,exception));
  }
catch (  PreconditionFailedException e) {
    message=MessageFormat.format("String_Node_Str" + "String_Node_Str",request.getResourceName(),request.getRequestType().toString(),resourceId);
    handler.handleError(new org.forgerock.json.resource.PreconditionFailedException(message,exception));
  }
catch (  PreconditionRequiredException e) {
    message=MessageFormat.format("String_Node_Str",request.getResourceName(),request.getRequestType().toString(),resourceId);
    handler.handleError(new org.forgerock.json.resource.PreconditionRequiredException(message,exception));
  }
catch (  RetryableException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  UnsupportedOperationException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new NotFoundException(message,exception));
  }
catch (  IllegalArgumentException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,e));
  }
catch (  RemoteWrappedException e) {
    handleRemoteWrappedException(context,request,exception,resourceId,before,after,handler,connectorExceptionActivityLogger);
  }
catch (  ConnectorException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,exception));
  }
 finally {
    logger.debug(message,exception);
    try {
      connectorExceptionActivityLogger.log(context,request.getRequestType(),message,resourceId,before,after,Status.FAILURE);
    }
 catch (    ResourceException e) {
      logger.warn("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Handle ConnectorExceptions from ConnectorFacade invocations.  Maps each ConnectorException subtype to the appropriate   {@link ResourceException} for passing to {@code handleError}.  Optionally logs to activity log.
 * @param context the ServerContext from the original request
 * @param request the original request
 * @param exception the ConnectorException that was thrown by the facade
 * @param resourceId the resourceId being operated on
 * @param before the object value "before" the request
 * @param after the object value "after" the request
 * @param handler the ResultHandler on which to call handleError
 * @param connectorExceptionActivityLogger the ActivityLogger to use to log the exception
 */
private void handleConnectorException(ServerContext context,Request request,ConnectorException exception,String resourceContainer,String resourceId,JsonValue before,JsonValue after,ResultHandler<?> handler,ActivityLogger connectorExceptionActivityLogger){
  String message=MessageFormat.format("String_Node_Str",request.getRequestType(),exception.getClass().getSimpleName(),resourceId);
  try {
    throw exception;
  }
 catch (  AlreadyExistsException e) {
    message=MessageFormat.format("String_Node_Str",resourceId);
    handler.handleError(new ConflictException(message,exception));
  }
catch (  ConfigurationException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,exception));
  }
catch (  ConnectionBrokenException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  ConnectionFailedException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  ConnectorIOException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  OperationTimeoutException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  PasswordExpiredException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ForbiddenException(message,exception));
  }
catch (  InvalidPasswordException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(ResourceException.getException(UNAUTHORIZED_ERROR_CODE,message,exception));
  }
catch (  UnknownUidException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId,resourceContainer);
    handler.handleError(new NotFoundException(message,exception).setDetail(new JsonValue(new HashMap<String,Object>())));
  }
catch (  InvalidCredentialException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(ResourceException.getException(UNAUTHORIZED_ERROR_CODE,message,exception));
  }
catch (  PermissionDeniedException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ForbiddenException(message,exception));
  }
catch (  ConnectorSecurityException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,exception));
  }
catch (  InvalidAttributeValueException e) {
    message=MessageFormat.format("String_Node_Str" + "String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new BadRequestException(message,exception));
  }
catch (  PreconditionFailedException e) {
    message=MessageFormat.format("String_Node_Str" + "String_Node_Str",resourceId,request.getRequestType().toString(),resourceContainer);
    handler.handleError(new org.forgerock.json.resource.PreconditionFailedException(message,exception));
  }
catch (  PreconditionRequiredException e) {
    message=MessageFormat.format("String_Node_Str",resourceId,request.getRequestType().toString(),resourceContainer);
    handler.handleError(new org.forgerock.json.resource.PreconditionRequiredException(message,exception));
  }
catch (  RetryableException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new ServiceUnavailableException(message,exception));
  }
catch (  UnsupportedOperationException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new NotFoundException(message,exception));
  }
catch (  IllegalArgumentException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,e));
  }
catch (  RemoteWrappedException e) {
    handleRemoteWrappedException(context,request,exception,resourceContainer,resourceId,before,after,handler,connectorExceptionActivityLogger);
  }
catch (  ConnectorException e) {
    message=MessageFormat.format("String_Node_Str",request.getRequestType().toString(),resourceId);
    handler.handleError(new InternalServerErrorException(message,exception));
  }
 finally {
    logger.debug(message,exception);
    try {
      connectorExceptionActivityLogger.log(context,request.getRequestType(),message,resourceId,before,after,Status.FAILURE);
    }
 catch (    ResourceException e) {
      logger.warn("String_Node_Str",e);
    }
  }
}