Program: 36684
Project: 36684
Buggy source:
/** 
 * Perform work as a particular <code>Subject</code>. <p> This method first retrieves the current Thread's <code>AccessControlContext</code> via <code>AccessController.getContext</code>, and then instantiates a new <code>AccessControlContext</code> using the retrieved context along with a new <code>SubjectDomainCombiner</code> (constructed using the provided <code>Subject</code>). Finally, this method invokes <code>AccessController.doPrivileged</code>, passing it the provided <code>PrivilegedExceptionAction</code>, as well as the newly constructed <code>AccessControlContext</code>. <p>
 * @param subject the <code>Subject</code> that the specified<code>action</code> will run as.  This parameter may be <code>null</code>. <p>
 * @param action the code to be run as the specified<code>Subject</code>. <p>
 * @return the value returned by thePrivilegedExceptionAction's <code>run</code> method.
 * @exception PrivilegedActionException if the<code>PrivilegedExceptionAction.run</code> method throws a checked exception. <p>
 * @exception NullPointerException if the specified<code>PrivilegedExceptionAction</code> is <code>null</code>. <p>
 * @exception SecurityException if the caller does not have permissionto invoke this method.
 */
public static <T>T doAs(final Subject subject,final java.security.PrivilegedExceptionAction<T> action) throws java.security.PrivilegedActionException {
  java.lang.SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION);
  }
  if (action == null)   throw new NullPointerException(ResourcesMgr.getString("String_Node_Str"));
  final AccessControlContext currentAcc=AccessController.getContext();
  return java.security.AccessController.doPrivileged(action,createContext(subject,currentAcc));
}

Fixed version (ground truth):
/** 
 * Perform work as a particular <code>Subject</code>. <p> This method first retrieves the current Thread's <code>AccessControlContext</code> via <code>AccessController.getContext</code>, and then instantiates a new <code>AccessControlContext</code> using the retrieved context along with a new <code>SubjectDomainCombiner</code> (constructed using the provided <code>Subject</code>). Finally, this method invokes <code>AccessController.doPrivileged</code>, passing it the provided <code>PrivilegedExceptionAction</code>, as well as the newly constructed <code>AccessControlContext</code>. <p>
 * @param subject the <code>Subject</code> that the specified<code>action</code> will run as.  This parameter may be <code>null</code>. <p>
 * @param < T > the type of the value returned by thePrivilegedExceptionAction's  {@code run} method.
 * @param action the code to be run as the specified<code>Subject</code>. <p>
 * @return the value returned by thePrivilegedExceptionAction's <code>run</code> method.
 * @exception PrivilegedActionException if the<code>PrivilegedExceptionAction.run</code> method throws a checked exception. <p>
 * @exception NullPointerException if the specified<code>PrivilegedExceptionAction</code> is <code>null</code>. <p>
 * @exception SecurityException if the caller does not have permissionto invoke this method.
 */
public static <T>T doAs(final Subject subject,final java.security.PrivilegedExceptionAction<T> action) throws java.security.PrivilegedActionException {
  java.lang.SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION);
  }
  if (action == null)   throw new NullPointerException(ResourcesMgr.getString("String_Node_Str"));
  final AccessControlContext currentAcc=AccessController.getContext();
  return java.security.AccessController.doPrivileged(action,createContext(subject,currentAcc));
}