Program: 28840
Project: 28840
Buggy source:
/** 
 * Determine whether the given Subject has been granted the specified Permission by delegating to the configured java.security.Policy object.  This method is a high-level convenience method that tests for a Subject-based permission grant without reference to the AccessControlContext of the caller. In addition, this method isolates the query from the underlying Policy configuration model.  It could, for example, multiplex queries across multiple instances of Policy configured in an implementation-specific way such that different threads, or different applications, query different Policy objects.  The initial implementation simply delegates to the configured Policy as defined by Java SE.
 * @param subject The Subject for which permission is being tested.
 * @param permission The Permission being queried.
 * @return True or false, depending on whether the specified Permissionis granted to the Subject by the configured Policy.
 * @throws IllegalArgumentException Given null or illegal subject or permission
 * @throws IllegalStateException Service was not initialized.
 * @see AuthorizationService#isPermissionGranted(javax.security.auth.Subject,java.security.Permission)
 */
@Override public boolean isPermissionGranted(final Subject subject,final Permission permission){
  checkServiceAvailability();
  final Boolean providerGrant=atzProvider.isPermissionGranted(subject,permission);
  if (null != providerGrant) {
    return providerGrant.booleanValue();
  }
  if (null == subject) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (null == permission) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Set<Principal> principalset=subject.getPrincipals();
  Principal[] principalAr=(principalset.size() == 0) ? null : principalset.toArray(new Principal[principalset.size()]);
  ProtectionDomain pd=new ProtectionDomain(NULL_CODESOURCE,null,null,principalAr);
  Policy policy=Policy.getPolicy();
  boolean result=policy.implies(pd,permission);
  return result;
}

Fixed version (ground truth):
/** 
 * Determine whether the given Subject has been granted the specified Permission by delegating to the configured java.security.Policy object.  This method is a high-level convenience method that tests for a Subject-based permission grant without reference to the AccessControlContext of the caller. In addition, this method isolates the query from the underlying Policy configuration model.  It could, for example, multiplex queries across multiple instances of Policy configured in an implementation-specific way such that different threads, or different applications, query different Policy objects.  The initial implementation simply delegates to the configured Policy as defined by Java SE.
 * @param subject The Subject for which permission is being tested.
 * @param permission The Permission being queried.
 * @return True or false, depending on whether the specified Permissionis granted to the Subject by the configured Policy.
 * @throws IllegalArgumentException Given null or illegal subject or permission
 * @see AuthorizationService#isPermissionGranted(javax.security.auth.Subject,java.security.Permission)
 */
@Override public boolean isPermissionGranted(final Subject subject,final Permission permission){
  if (null == subject) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (null == permission) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Set<Principal> principalset=subject.getPrincipals();
  Principal[] principalAr=(principalset.size() == 0) ? null : principalset.toArray(new Principal[principalset.size()]);
  ProtectionDomain pd=new ProtectionDomain(NULL_CODESOURCE,null,null,principalAr);
  Policy policy=Policy.getPolicy();
  boolean result=policy.implies(pd,permission);
  return result;
}