Program: 79896
Project: 79896
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void updateInstance(final ServerContext context,final String resourceId,final UpdateRequest request,final ResultHandler<Resource> handler){
  Token admin=new Token();
  admin.setId(getCookieFromServerContext(context));
  final JsonValue jVal=request.getNewContent();
  final String rev=request.getRevision();
  IdentityDetails dtls=null, newDtls=null;
  IdentityServicesImpl idsvc=null;
  Resource resource=null;
  try {
    idsvc=new IdentityServicesImpl();
    dtls=idsvc.read(resourceId,idSvcsAttrList,admin);
    newDtls=jsonValueToIdentityDetails(jVal);
    newDtls.setName(resourceId);
    String userpass=jVal.get("String_Node_Str").asString();
    if (userpass != null && !userpass.isEmpty()) {
      if (checkValidPassword(resourceId,userpass.toCharArray(),realm) || isAdmin(context)) {
      }
 else {
        if (checkValidPassword(resourceId,getPasswordFromHeader(context).toCharArray(),realm)) {
        }
 else {
          throw new PermanentException(401,"String_Node_Str",null);
        }
      }
    }
    UpdateResponse message=idsvc.update(newDtls,admin);
    IdentityDetails checkIdent=idsvc.read(dtls.getName(),idSvcsAttrList,admin);
    resource=new Resource(resourceId,"String_Node_Str",identityDetailsToJsonValue(checkIdent));
    handler.handleResult(resource);
  }
 catch (  final ObjectNotFound o) {
    try {
      dtls=jsonValueToIdentityDetails(jVal);
      dtls.setName(resourceId);
      CreateResponse success=idsvc.create(dtls,admin);
      IdentityDetails checkIdent=idsvc.read(dtls.getName(),idSvcsAttrList,admin);
      resource=new Resource(resourceId,"String_Node_Str",identityDetailsToJsonValue(checkIdent));
      handler.handleResult(resource);
    }
 catch (    final TokenExpired tokenExpired) {
      RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ tokenExpired);
      handler.handleError(new PermanentException(401,"String_Node_Str",null));
    }
catch (    final Exception e) {
      RestDispatcher.debug.error("String_Node_Str" + e);
      handler.handleError(new BadRequestException(e.getMessage(),e));
    }
  }
catch (  final NeedMoreCredentials needMoreCredentials) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ needMoreCredentials);
    handler.handleError(new ForbiddenException("String_Node_Str",needMoreCredentials));
  }
catch (  final TokenExpired tokenExpired) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ tokenExpired);
    handler.handleError(new PermanentException(401,"String_Node_Str",null));
  }
catch (  final AccessDenied accessDenied) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ accessDenied);
    handler.handleError(new ForbiddenException(accessDenied.getMessage(),accessDenied));
  }
catch (  final GeneralFailure generalFailure) {
    RestDispatcher.debug.error("String_Node_Str" + generalFailure);
    handler.handleError(new BadRequestException(generalFailure.getMessage(),generalFailure));
  }
catch (  final Exception exception) {
    RestDispatcher.debug.error("String_Node_Str" + exception);
    handler.handleError(new NotFoundException(exception.getMessage(),exception));
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void updateInstance(final ServerContext context,final String resourceId,final UpdateRequest request,final ResultHandler<Resource> handler){
  Token admin=new Token();
  admin.setId(getCookieFromServerContext(context));
  final JsonValue jVal=request.getNewContent();
  final String rev=request.getRevision();
  IdentityDetails dtls=null, newDtls=null;
  IdentityServicesImpl idsvc=null;
  Resource resource=null;
  try {
    idsvc=new IdentityServicesImpl();
    dtls=idsvc.read(resourceId,idSvcsAttrList,admin);
    newDtls=jsonValueToIdentityDetails(jVal);
    newDtls.setName(resourceId);
    String userpass=jVal.get("String_Node_Str").asString();
    if (userpass != null && !userpass.isEmpty()) {
      if (checkValidPassword(resourceId,userpass.toCharArray(),realm) || isAdmin(context)) {
      }
 else {
        String strPass=getPasswordFromHeader(context);
        if (strPass != null && !strPass.isEmpty() && checkValidPassword(resourceId,strPass.toCharArray(),realm)) {
        }
 else {
          throw new ForbiddenException("String_Node_Str",null);
        }
      }
    }
    UpdateResponse message=idsvc.update(newDtls,admin);
    IdentityDetails checkIdent=idsvc.read(dtls.getName(),idSvcsAttrList,admin);
    resource=new Resource(resourceId,"String_Node_Str",identityDetailsToJsonValue(checkIdent));
    handler.handleResult(resource);
  }
 catch (  final ObjectNotFound o) {
    try {
      dtls=jsonValueToIdentityDetails(jVal);
      dtls.setName(resourceId);
      CreateResponse success=idsvc.create(dtls,admin);
      IdentityDetails checkIdent=idsvc.read(dtls.getName(),idSvcsAttrList,admin);
      resource=new Resource(resourceId,"String_Node_Str",identityDetailsToJsonValue(checkIdent));
      handler.handleResult(resource);
    }
 catch (    final TokenExpired tokenExpired) {
      RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ tokenExpired);
      handler.handleError(new PermanentException(401,"String_Node_Str",null));
    }
catch (    final Exception e) {
      RestDispatcher.debug.error("String_Node_Str" + e);
      handler.handleError(new BadRequestException(e.getMessage(),e));
    }
  }
catch (  final NeedMoreCredentials needMoreCredentials) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ needMoreCredentials);
    handler.handleError(new ForbiddenException("String_Node_Str",needMoreCredentials));
  }
catch (  final TokenExpired tokenExpired) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ tokenExpired);
    handler.handleError(new PermanentException(401,"String_Node_Str",null));
  }
catch (  final AccessDenied accessDenied) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ accessDenied);
    handler.handleError(new ForbiddenException(accessDenied.getMessage(),accessDenied));
  }
catch (  final GeneralFailure generalFailure) {
    RestDispatcher.debug.error("String_Node_Str" + generalFailure);
    handler.handleError(new BadRequestException(generalFailure.getMessage(),generalFailure));
  }
catch (  ForbiddenException fe) {
    RestDispatcher.debug.error("String_Node_Str" + resourceId + "String_Node_Str"+ fe);
    handler.handleError(fe);
  }
catch (  final Exception exception) {
    RestDispatcher.debug.error("String_Node_Str" + exception);
    handler.handleError(new NotFoundException(exception.getMessage(),exception));
  }
}