Program: 14833
Project: 14833
Buggy source:
/** 
 * Uses the provided   {@code lookupFunction} to resolve the {@code identifier} to the underlyingobject  {@code T} with privileges determined by the current messaging context.
 * @param < T > type of object which needs looking up
 * @param identifier identifier of the desired object
 * @param resolverFunction class which resolves string identifiers to the underlying object
 * @return the object corresponding with the given {@code identifier}
 * @throws AuthException if the user is not authorized
 * @throws PersistenceException if an error occurred in the underlying retrieval mechanism
 * @throws NoSuchElementException if the requested {@code identifier} does not exist and the useris authorized.
 * @throws IllegalContextAccessException if the current request context cannot be determined.
 */
@SuppressWarnings("String_Node_Str") public static <T extends RestrictedType>T doPrivileged(String identifier,Function<String,T> resolverFunction,boolean ignoreOwningAccount) throws AuthException, IllegalContextAccessException, NoSuchElementException, PersistenceException {
  assertThat("String_Node_Str" + identifier,resolverFunction,notNullValue());
  Context ctx=Contexts.lookup();
  if (ctx.hasAdministrativePrivileges()) {
    return resolverFunction.apply(identifier);
  }
 else {
    Class<? extends BaseMessage> msgType=ctx.getRequest().getClass();
    LOG.debug("String_Node_Str" + identifier + "String_Node_Str"+ resolverFunction.getClass()+ "String_Node_Str"+ Classes.genericsToClasses(resolverFunction));
    Class<?> rscType=findResourceClass(resolverFunction);
    Ats ats=findPolicyAnnotations(rscType,msgType);
    PolicyVendor vendor=ats.get(PolicyVendor.class);
    PolicyResourceType type=ats.get(PolicyResourceType.class);
    String action=getIamActionByMessageType();
    User requestUser=ctx.getUser();
    T requestedObject;
    try {
      requestedObject=resolverFunction.apply(identifier);
      if (requestedObject == null) {
        throw new NoSuchElementException("String_Node_Str" + rscType.getCanonicalName() + "String_Node_Str"+ identifier+ "String_Node_Str"+ resolverFunction.getClass());
      }
    }
 catch (    NoSuchElementException ex) {
      throw ex;
    }
catch (    PersistenceException ex) {
      Logs.extreme().error(ex,ex);
      LOG.error(ex);
      throw ex;
    }
catch (    Exception ex) {
      Logs.extreme().error(ex,ex);
      LOG.error(ex);
      throw new PersistenceException("String_Node_Str" + identifier + "String_Node_Str"+ resolverFunction.getClass()+ "String_Node_Str"+ rscType,ex);
    }
    Account owningAccount=null;
    if (!ignoreOwningAccount) {
      owningAccount=Principals.nobodyFullName().getAccountNumber().equals(requestedObject.getOwner().getAccountNumber()) ? null : Accounts.lookupAccountByName(requestedObject.getOwner().getAccountName());
    }
    if (!Permissions.isAuthorized(vendor.value(),type.value(),identifier,owningAccount,action,requestUser)) {
      throw new AuthException("String_Node_Str" + type.value() + "String_Node_Str"+ identifier+ "String_Node_Str"+ UserFullName.getInstance(requestUser));
    }
    return requestedObject;
  }
}

Fixed version (ground truth):
/** 
 * Uses the provided   {@code lookupFunction} to resolve the {@code identifier} to the underlyingobject  {@code T} with privileges determined by the current messaging context.
 * @param < T > type of object which needs looking up
 * @param identifier identifier of the desired object
 * @param resolverFunction class which resolves string identifiers to the underlying object
 * @return the object corresponding with the given {@code identifier}
 * @throws AuthException if the user is not authorized
 * @throws PersistenceException if an error occurred in the underlying retrieval mechanism
 * @throws NoSuchElementException if the requested {@code identifier} does not exist and the useris authorized.
 * @throws IllegalContextAccessException if the current request context cannot be determined.
 */
@SuppressWarnings("String_Node_Str") private static <T extends RestrictedType>T doPrivileged(String identifier,Function<String,T> resolverFunction,boolean ignoreOwningAccount) throws AuthException, IllegalContextAccessException, NoSuchElementException, PersistenceException {
  assertThat("String_Node_Str" + identifier,resolverFunction,notNullValue());
  Context ctx=Contexts.lookup();
  if (ctx.hasAdministrativePrivileges()) {
    return resolverFunction.apply(identifier);
  }
 else {
    Class<? extends BaseMessage> msgType=ctx.getRequest().getClass();
    LOG.debug("String_Node_Str" + identifier + "String_Node_Str"+ resolverFunction.getClass()+ "String_Node_Str"+ Classes.genericsToClasses(resolverFunction));
    Class<?> rscType=findResourceClass(resolverFunction);
    Ats ats=findPolicyAnnotations(rscType,msgType);
    PolicyVendor vendor=ats.get(PolicyVendor.class);
    PolicyResourceType type=ats.get(PolicyResourceType.class);
    String action=getIamActionByMessageType();
    User requestUser=ctx.getUser();
    T requestedObject;
    try {
      requestedObject=resolverFunction.apply(identifier);
      if (requestedObject == null) {
        throw new NoSuchElementException("String_Node_Str" + rscType.getCanonicalName() + "String_Node_Str"+ identifier+ "String_Node_Str"+ resolverFunction.getClass());
      }
    }
 catch (    NoSuchElementException ex) {
      throw ex;
    }
catch (    PersistenceException ex) {
      Logs.extreme().error(ex,ex);
      LOG.error(ex);
      throw ex;
    }
catch (    Exception ex) {
      Logs.extreme().error(ex,ex);
      LOG.error(ex);
      throw new PersistenceException("String_Node_Str" + identifier + "String_Node_Str"+ resolverFunction.getClass()+ "String_Node_Str"+ rscType,ex);
    }
    Account owningAccount=null;
    if (!ignoreOwningAccount) {
      owningAccount=Principals.nobodyFullName().getAccountNumber().equals(requestedObject.getOwner().getAccountNumber()) ? null : Accounts.lookupAccountByName(requestedObject.getOwner().getAccountName());
    }
    if (!Permissions.isAuthorized(vendor.value(),type.value(),identifier,owningAccount,action,requestUser)) {
      throw new AuthException("String_Node_Str" + type.value() + "String_Node_Str"+ identifier+ "String_Node_Str"+ UserFullName.getInstance(requestUser));
    }
    return requestedObject;
  }
}