nus-yam/ex-repair huggingface dataset:
Program: 30420
Project: 30420
Buggy source:
private void removePolicyContextDirectory(){
  String directoryName=getContextDirectoryName();
  File f=new File(directoryName);
  if (f.exists()) {
    File[] files=f.listFiles();
    if (files != null && files.length > 0) {
      for (int i=0; i < files.length; i++) {
        files[i].delete();
      }
    }
    if (!f.delete()) {
      String defMsg="String_Node_Str" + directoryName;
      String msg=localStrings.getLocalString("String_Node_Str",defMsg);
      logger.log(Level.SEVERE,msg);
      throw new RuntimeException(defMsg);
    }
 else     if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + directoryName);
    }
    File appDir=f.getParentFile();
    File[] fs=appDir.listFiles();
    if (fs != null && fs.length > 0) {
      boolean hasDir=false;
      for (int i=0; i < fs.length; i++) {
        if (fs[i].isDirectory()) {
          hasDir=true;
          break;
        }
      }
      if (!hasDir) {
        for (int i=0; i < fs.length; i++) {
          fs[i].delete();
        }
      }
    }
    File[] moduleDirs=appDir.listFiles();
    if (moduleDirs == null || moduleDirs.length == 0) {
      if (!appDir.delete()) {
        String defMsg="String_Node_Str" + appDir;
        String msg=localStrings.getLocalString("String_Node_Str",defMsg);
        logger.log(Level.SEVERE,msg);
        throw new RuntimeException(defMsg);
      }
    }
  }
}

Fixed version (ground truth):
private void removePolicyContextDirectory(){
  String directoryName=getContextDirectoryName();
  File f=new File(directoryName);
  if (f.exists()) {
    File[] files=f.listFiles();
    if (files != null && files.length > 0) {
      for (int i=0; i < files.length; i++) {
        if (!files[i].delete()) {
          String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str");
          logger.log(Level.SEVERE,msg);
          throw new RuntimeException(msg);
        }
      }
    }
    if (!f.delete()) {
      String defMsg="String_Node_Str" + directoryName;
      String msg=localStrings.getLocalString("String_Node_Str",defMsg);
      logger.log(Level.SEVERE,msg);
      throw new RuntimeException(defMsg);
    }
 else     if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + directoryName);
    }
    File appDir=f.getParentFile();
    File[] fs=appDir.listFiles();
    if (fs != null && fs.length > 0) {
      boolean hasDir=false;
      for (int i=0; i < fs.length; i++) {
        if (fs[i].isDirectory()) {
          hasDir=true;
          break;
        }
      }
      if (!hasDir) {
        for (int i=0; i < fs.length; i++) {
          fs[i].delete();
        }
      }
    }
    File[] moduleDirs=appDir.listFiles();
    if (moduleDirs == null || moduleDirs.length == 0) {
      if (!appDir.delete()) {
        String defMsg="String_Node_Str" + appDir;
        String msg=localStrings.getLocalString("String_Node_Str",defMsg);
        logger.log(Level.SEVERE,msg);
        throw new RuntimeException(defMsg);
      }
    }
  }
}
Program: 30421
Project: 30421
Buggy source:
private void createPolicyContextDirectory(){
  String contextDirectoryName=getContextDirectoryName();
  File d=new File(contextDirectoryName);
  if (d.exists()) {
    if (!d.isDirectory()) {
      String defMsg="String_Node_Str";
      String msg=localStrings.getLocalString("String_Node_Str",defMsg,new Object[]{contextDirectoryName});
      logger.log(Level.SEVERE,msg);
      throw new RuntimeException(defMsg);
    }
  }
 else {
    d.mkdirs();
  }
}

Fixed version (ground truth):
private void createPolicyContextDirectory(){
  String contextDirectoryName=getContextDirectoryName();
  File d=new File(contextDirectoryName);
  String defMsg="String_Node_Str";
  String msg=localStrings.getLocalString("String_Node_Str",defMsg,new Object[]{contextDirectoryName});
  if (d.exists()) {
    if (!d.isDirectory()) {
      logger.log(Level.SEVERE,msg);
      throw new RuntimeException(defMsg);
    }
  }
 else {
    if (!d.mkdirs()) {
      logger.log(Level.SEVERE,msg);
      throw new RuntimeException(defMsg);
    }
  }
}
Program: 30422
Project: 30422
Buggy source:
private void configureStandardHostValve(StandardHostValve host){
  if ((errorReportValveClass != null) && !"String_Node_Str".equals(errorReportValveClass)) {
    try {
      GlassFishValve valve=(GlassFishValve)Class.forName(errorReportValveClass).newInstance();
      host.setErrorReportValve(valve);
    }
 catch (    Throwable t) {
      log.log(Level.SEVERE,sm.getString("String_Node_Str",errorReportValveClass),t);
    }
  }
}

Fixed version (ground truth):
public void configureStandardHostValve(StandardHostValve host){
  if ((errorReportValveClass != null) && !"String_Node_Str".equals(errorReportValveClass)) {
    try {
      GlassFishValve valve=(GlassFishValve)Class.forName(errorReportValveClass).newInstance();
      host.setErrorReportValve(valve);
    }
 catch (    Throwable t) {
      log.log(Level.SEVERE,sm.getString("String_Node_Str",errorReportValveClass),t);
    }
  }
}
Program: 30423
Project: 30423
Buggy source:
void setErrorReportValve(GlassFishValve errorReportValve){
  this.errorReportValve=errorReportValve;
}

Fixed version (ground truth):
public void setErrorReportValve(GlassFishValve errorReportValve){
  this.errorReportValve=errorReportValve;
}
Program: 30424
Project: 30424
Buggy source:
public void configureStandardHostValve(StandardHostValve host){
  if ((errorReportValveClass != null) && !"String_Node_Str".equals(errorReportValveClass)) {
    try {
      GlassFishValve valve=(GlassFishValve)Class.forName(errorReportValveClass).newInstance();
      host.setErrorReportValve(valve);
    }
 catch (    Throwable t) {
      log.log(Level.SEVERE,sm.getString("String_Node_Str",errorReportValveClass),t);
    }
  }
}

Fixed version (ground truth):
private void configureStandardHostValve(StandardHostValve host){
  if ((errorReportValveClass != null) && !"String_Node_Str".equals(errorReportValveClass)) {
    try {
      GlassFishValve valve=(GlassFishValve)loadInstance(errorReportValveClass);
      host.setErrorReportValve(valve);
    }
 catch (    Throwable t) {
      log.log(Level.SEVERE,sm.getString("String_Node_Str",errorReportValveClass),t);
    }
  }
}
Program: 30425
Project: 30425
Buggy source:
public void setErrorReportValve(GlassFishValve errorReportValve){
  this.errorReportValve=errorReportValve;
}

Fixed version (ground truth):
void setErrorReportValve(GlassFishValve errorReportValve){
  this.errorReportValve=errorReportValve;
}
Program: 30426
Project: 30426
Buggy source:
private Object loadInstance(String className){
  try {
    Class clazz=serverContext.getCommonClassLoader().loadClass(className);
    return clazz.newInstance();
  }
 catch (  Throwable ex) {
    _logger.log(Level.SEVERE,"String_Node_Str",ex);
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object loadInstance(String className) throws Exception {
  Class clazz=serverContext.getCommonClassLoader().loadClass(className);
  return clazz.newInstance();
}
Program: 30427
Project: 30427
Buggy source:
/** 
 * Adds the <code>Valve</code> with the given class name to this VirtualServer.
 * @param valveName The valve's fully qualified class nam
 */
protected void addValve(String valveName){
  Object valve=loadInstance(valveName);
  if (valve instanceof Valve) {
    addValve((Valve)valve);
  }
 else   if (valve instanceof GlassFishValve) {
    addValve((GlassFishValve)valve);
  }
 else {
    _logger.log(Level.WARNING,"String_Node_Str",valveName);
  }
}

Fixed version (ground truth):
/** 
 * Adds the <code>Valve</code> with the given class name to this VirtualServer.
 * @param valveName The valve's fully qualified class nam
 */
protected void addValve(String valveName){
  Object valve=safeLoadInstance(valveName);
  if (valve instanceof Valve) {
    addValve((Valve)valve);
  }
 else   if (valve instanceof GlassFishValve) {
    addValve((GlassFishValve)valve);
  }
 else {
    _logger.log(Level.WARNING,"String_Node_Str",valveName);
  }
}
Program: 30428
Project: 30428
Buggy source:
/** 
 * Adds the Catalina listener with the given class name to this VirtualServer.
 * @param listenerName The fully qualified class name of the listener
 */
protected void addListener(String listenerName){
  Object listener=loadInstance(listenerName);
  if (listener == null)   return;
  if (listener instanceof ContainerListener) {
    addContainerListener((ContainerListener)listener);
  }
 else   if (listener instanceof LifecycleListener) {
    addLifecycleListener((LifecycleListener)listener);
  }
 else {
    _logger.log(Level.SEVERE,"String_Node_Str",new Object[]{listenerName,getID()});
  }
}

Fixed version (ground truth):
/** 
 * Adds the Catalina listener with the given class name to this VirtualServer.
 * @param listenerName The fully qualified class name of the listener
 */
protected void addListener(String listenerName){
  Object listener=safeLoadInstance(listenerName);
  if (listener == null)   return;
  if (listener instanceof ContainerListener) {
    addContainerListener((ContainerListener)listener);
  }
 else   if (listener instanceof LifecycleListener) {
    addLifecycleListener((LifecycleListener)listener);
  }
 else {
    _logger.log(Level.SEVERE,"String_Node_Str",new Object[]{listenerName,getID()});
  }
}
Program: 30430
Project: 30430
Buggy source:
/** 
 * Returns the element name used by the parent to store instances of the child
 * @param document the dom document this configuration element lives in.
 * @param parent type of the parent
 * @param child type of the child
 * @return the element name holding child's instances in the parent
 * @throws ClassNotFoundException when subclasses cannot be loaded
 */
public static String elementName(DomDocument document,Class<?> parent,Class<?> child) throws ClassNotFoundException {
  ConfigModel cm=document.buildModel(parent);
  for (  String elementName : cm.getElementNames()) {
    ConfigModel.Property prop=cm.getElement(elementName);
    if (prop instanceof ConfigModel.Node) {
      ConfigModel childCM=((ConfigModel.Node)prop).getModel();
      String childTypeName=childCM.targetTypeName;
      if (childTypeName.equals(child.getName())) {
        return elementName;
      }
      List<ConfigModel> subChildrenModels=document.getAllModelsImplementing(childCM.classLoaderHolder.get().loadClass(childTypeName));
      if (subChildrenModels != null) {
        for (        ConfigModel subChildModel : subChildrenModels) {
          if (subChildModel.targetTypeName.equals(child.getName())) {
            return elementName;
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the element name used by the parent to store instances of the child
 * @param document the dom document this configuration element lives in.
 * @param parent type of the parent
 * @param child type of the child
 * @return the element name holding child's instances in the parent
 * @throws ClassNotFoundException when subclasses cannot be loaded
 */
public static String elementName(DomDocument document,Class<?> parent,Class<?> child) throws ClassNotFoundException {
  ConfigModel cm=document.buildModel(parent);
  for (  String elementName : cm.getElementNames()) {
    ConfigModel.Property prop=cm.getElement(elementName);
    if (prop instanceof ConfigModel.Node) {
      ConfigModel childCM=((ConfigModel.Node)prop).getModel();
      String childTypeName=childCM.targetTypeName;
      if (childTypeName.equals(child.getName())) {
        return childCM.getTagName();
      }
      List<ConfigModel> subChildrenModels=document.getAllModelsImplementing(childCM.classLoaderHolder.get().loadClass(childTypeName));
      if (subChildrenModels != null) {
        for (        ConfigModel subChildModel : subChildrenModels) {
          if (subChildModel.targetTypeName.equals(child.getName())) {
            return subChildModel.getTagName();
          }
        }
      }
    }
  }
  return null;
}
Program: 30431
Project: 30431
Buggy source:
private EJBHomeImpl instantiateEJBHomeImpl() throws Exception {
  EJBHomeInvocationHandler handler=new EJBHomeInvocationHandler(ejbDescriptor,homeIntf,proxyInvocationInfoMap);
  EJBHomeImpl homeImpl=handler;
  Set proxyInterfacesSet=new LinkedHashSet();
  if (ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean()) {
    proxyInterfacesSet.add(ReadOnlyEJBHome.class);
  }
  proxyInterfacesSet.add(homeIntf);
  Class[] proxyInterfaces=(Class[])proxyInterfacesSet.toArray(new Class[proxyInterfacesSet.size()]);
  EJBHome ejbHomeProxy=(EJBHome)Proxy.newProxyInstance(loader,proxyInterfaces,handler);
  handler.setProxy(ejbHomeProxy);
  homeImpl.setContainer(this);
  return homeImpl;
}

Fixed version (ground truth):
private EJBHomeImpl instantiateEJBHomeImpl() throws Exception {
  EJBHomeInvocationHandler handler=new EJBHomeInvocationHandler(ejbDescriptor,homeIntf,proxyInvocationInfoMap);
  EJBHomeImpl homeImpl=handler;
  Set proxyInterfacesSet=new LinkedHashSet();
  if (ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean()) {
    proxyInterfacesSet.add(ReadOnlyEJBHome.class);
  }
  proxyInterfacesSet.add(homeIntf);
  Class[] proxyInterfaces=(Class[])proxyInterfacesSet.toArray(new Class[proxyInterfacesSet.size()]);
  try {
    EJBHome ejbHomeProxy=(EJBHome)Proxy.newProxyInstance(loader,proxyInterfaces,handler);
    handler.setProxy(ejbHomeProxy);
  }
 catch (  ClassCastException e) {
    String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",homeIntf);
    throw new IllegalArgumentException(msg,e);
  }
  homeImpl.setContainer(this);
  return homeImpl;
}
Program: 30432
Project: 30432
Buggy source:
private EJBLocalHomeImpl instantiateEJBLocalHomeImpl() throws Exception {
  EJBLocalHomeInvocationHandler invHandler=new EJBLocalHomeInvocationHandler(ejbDescriptor,localHomeIntf,proxyInvocationInfoMap);
  EJBLocalHomeImpl homeImpl=invHandler;
  Set proxyInterfacesSet=new LinkedHashSet();
  proxyInterfacesSet.add(IndirectlySerializable.class);
  if (ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean()) {
    proxyInterfacesSet.add(ReadOnlyEJBLocalHome.class);
  }
  proxyInterfacesSet.add(localHomeIntf);
  Class[] proxyInterfaces=(Class[])proxyInterfacesSet.toArray(new Class[proxyInterfacesSet.size()]);
  EJBLocalHome proxy=(EJBLocalHome)Proxy.newProxyInstance(loader,proxyInterfaces,invHandler);
  invHandler.setProxy(proxy);
  homeImpl.setContainer(this);
  return homeImpl;
}

Fixed version (ground truth):
private EJBLocalHomeImpl instantiateEJBLocalHomeImpl() throws Exception {
  EJBLocalHomeInvocationHandler invHandler=new EJBLocalHomeInvocationHandler(ejbDescriptor,localHomeIntf,proxyInvocationInfoMap);
  EJBLocalHomeImpl homeImpl=invHandler;
  Set proxyInterfacesSet=new LinkedHashSet();
  proxyInterfacesSet.add(IndirectlySerializable.class);
  if (ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean()) {
    proxyInterfacesSet.add(ReadOnlyEJBLocalHome.class);
  }
  proxyInterfacesSet.add(localHomeIntf);
  Class[] proxyInterfaces=(Class[])proxyInterfacesSet.toArray(new Class[proxyInterfacesSet.size()]);
  try {
    EJBLocalHome proxy=(EJBLocalHome)Proxy.newProxyInstance(loader,proxyInterfaces,invHandler);
    invHandler.setProxy(proxy);
  }
 catch (  ClassCastException e) {
    String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",localHomeIntf);
    throw new IllegalArgumentException(msg,e);
  }
  homeImpl.setContainer(this);
  return homeImpl;
}
Program: 30433
Project: 30433
Buggy source:
protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl() throws Exception {
  EJBLocalObjectImpl localObjImpl=null;
  EJBLocalObjectInvocationHandler handler=new EJBLocalObjectInvocationHandler(proxyInvocationInfoMap,localIntf);
  localObjImpl=handler;
  EJBLocalObject localObjectProxy=(EJBLocalObject)ejbLocalObjectProxyCtor.newInstance(new Object[]{handler});
  handler.setProxy(localObjectProxy);
  localObjImpl.setContainer(this);
  return localObjImpl;
}

Fixed version (ground truth):
protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl() throws Exception {
  EJBLocalObjectImpl localObjImpl=null;
  EJBLocalObjectInvocationHandler handler=new EJBLocalObjectInvocationHandler(proxyInvocationInfoMap,localIntf);
  localObjImpl=handler;
  try {
    EJBLocalObject localObjectProxy=(EJBLocalObject)ejbLocalObjectProxyCtor.newInstance(new Object[]{handler});
    handler.setProxy(localObjectProxy);
  }
 catch (  ClassCastException e) {
    String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",localIntf);
    throw new IllegalArgumentException(msg,e);
  }
  localObjImpl.setContainer(this);
  return localObjImpl;
}
Program: 30434
Project: 30434
Buggy source:
protected EJBObjectImpl instantiateEJBObjectImpl() throws Exception {
  EJBObjectInvocationHandler handler=new EJBObjectInvocationHandler(proxyInvocationInfoMap,remoteIntf);
  EJBObjectImpl ejbObjImpl=handler;
  EJBObject ejbObjectProxy=(EJBObject)ejbObjectProxyCtor.newInstance(new Object[]{handler});
  handler.setEJBObject(ejbObjectProxy);
  ejbObjImpl.setContainer(this);
  return ejbObjImpl;
}

Fixed version (ground truth):
protected EJBObjectImpl instantiateEJBObjectImpl() throws Exception {
  EJBObjectInvocationHandler handler=new EJBObjectInvocationHandler(proxyInvocationInfoMap,remoteIntf);
  EJBObjectImpl ejbObjImpl=handler;
  try {
    EJBObject ejbObjectProxy=(EJBObject)ejbObjectProxyCtor.newInstance(new Object[]{handler});
    handler.setEJBObject(ejbObjectProxy);
  }
 catch (  ClassCastException e) {
    String msg=localStrings.getLocalString("String_Node_Str","String_Node_Str",remoteIntf);
    throw new IllegalArgumentException(msg,e);
  }
  ejbObjImpl.setContainer(this);
  return ejbObjImpl;
}
Program: 30436
Project: 30436
Buggy source:
public ApplicationInfo unload(ApplicationInfo info,ExtendedDeploymentContext context){
  ActionReport report=context.getActionReport();
  if (info == null) {
    report.failure(context.getLogger(),"String_Node_Str",null);
    return null;
  }
  if (info.isLoaded()) {
    info.stop(context,context.getLogger());
    info.unload(context);
    events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_DISABLED,info));
  }
  try {
    info.clean(context);
  }
 catch (  Exception e) {
    report.failure(context.getLogger(),"String_Node_Str",e);
    return info;
  }
  return info;
}

Fixed version (ground truth):
public ApplicationInfo unload(ApplicationInfo info,ExtendedDeploymentContext context){
  ActionReport report=context.getActionReport();
  if (info == null) {
    report.failure(context.getLogger(),"String_Node_Str",null);
    return null;
  }
  if (info.isLoaded()) {
    info.stop(context,context.getLogger());
    info.unload(context);
    events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_DISABLED,info),false);
  }
  try {
    info.clean(context);
  }
 catch (  Exception e) {
    report.failure(context.getLogger(),"String_Node_Str",e);
    return info;
  }
  return info;
}
Program: 30437
Project: 30437
Buggy source:
/** 
 * Sets the ejb descriptor to which I refer.
 * @param ejbDescriptor the ejb descriptor referenced, null if it is unknow at this time
 */
public void setEjbDescriptor(EjbDescriptor ejbDescriptor){
  if (this.ejbDescriptor != null) {
    this.ejbDescriptor.removeEjbReferencer(this);
  }
  this.ejbDescriptor=ejbDescriptor;
  if (ejbDescriptor != null) {
    ejbDescriptor.addEjbReferencer(this);
    if (isLocal()) {
      if (!ejbDescriptor.isLocalInterfacesSupported() && !ejbDescriptor.isLocalBusinessInterfacesSupported() && !ejbDescriptor.isLocalBean()) {
        throw new RuntimeException(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
      }
    }
 else {
      if (!ejbDescriptor.isRemoteInterfacesSupported() && !ejbDescriptor.isRemoteBusinessInterfacesSupported()) {
        throw new RuntimeException(localStrings.getLocalString("String_Node_Str","String_Node_Str"));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the ejb descriptor to which I refer.
 * @param ejbDescriptor the ejb descriptor referenced, null if it is unknow at this time
 */
public void setEjbDescriptor(EjbDescriptor ejbDescriptor){
  if (this.ejbDescriptor != null) {
    this.ejbDescriptor.removeEjbReferencer(this);
  }
  this.ejbDescriptor=ejbDescriptor;
  if (ejbDescriptor != null) {
    ejbDescriptor.addEjbReferencer(this);
    if (isLocal()) {
      if (!ejbDescriptor.isLocalInterfacesSupported() && !ejbDescriptor.isLocalBusinessInterfacesSupported() && !ejbDescriptor.isLocalBean()) {
        throw new RuntimeException(localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{ejbDescriptor.getName()}));
      }
    }
 else {
      if (!ejbDescriptor.isRemoteInterfacesSupported() && !ejbDescriptor.isRemoteBusinessInterfacesSupported()) {
        throw new RuntimeException(localStrings.getLocalString("String_Node_Str","String_Node_Str",new Object[]{ejbDescriptor.getName()}));
      }
    }
  }
}
Program: 30439
Project: 30439
Buggy source:
public void onInitialization(){
  try {
    if (_logger.isLoggable(Level.INFO)) {
      _logger.log(Level.INFO,"String_Node_Str");
    }
    webStatsProvider=new WebSecurityDeployerStatsProvider();
    StatsProviderManager.register("String_Node_Str",PluginPoint.SERVER,"String_Node_Str",webStatsProvider);
    initializeJMAC();
    policyLoader.loadPolicy();
    realmsManager.createRealms();
    AuditManager auditManager=secServUtil.getAuditManager();
    auditManager.loadAuditModules();
    auditManager.serverStarted();
    if (_logger.isLoggable(Level.INFO)) {
      _logger.log(Level.INFO,"String_Node_Str");
    }
  }
 catch (  Exception ex) {
    throw new SecurityLifecycleException(ex);
  }
}

Fixed version (ground truth):
public void onInitialization(){
  try {
    if (_logger.isLoggable(Level.INFO)) {
      _logger.log(Level.INFO,"String_Node_Str");
    }
    initializeJMAC();
    policyLoader.loadPolicy();
    realmsManager.createRealms();
    AuditManager auditManager=secServUtil.getAuditManager();
    auditManager.loadAuditModules();
    auditManager.serverStarted();
    if (_logger.isLoggable(Level.INFO)) {
      _logger.log(Level.INFO,"String_Node_Str");
    }
  }
 catch (  Exception ex) {
    throw new SecurityLifecycleException(ex);
  }
}
Program: 30440
Project: 30440
Buggy source:
private boolean deleteFile(File path){
  if (path != null && path.exists()) {
    if (path.isDirectory()) {
      File[] files=path.listFiles();
      for (      File file : files) {
        if (file.isDirectory()) {
          deleteFile(file);
          file.delete();
        }
 else {
          file.delete();
        }
      }
    }
    path.delete();
  }
  return true;
}

Fixed version (ground truth):
private boolean deleteFile(File path){
  if (path != null && path.exists()) {
    if (path.isDirectory()) {
      File[] files=path.listFiles();
      for (      File file : files) {
        if (file.isDirectory()) {
          deleteFile(file);
          if (file.delete())           continue;
        }
 else {
          if (file.delete())           continue;
        }
      }
    }
    path.delete();
  }
  return true;
}
Program: 30441
Project: 30441
Buggy source:
/** 
 * Logout the user. <p> This method removes the <code>PrincipalImpl</code> that was added by the <code>commit</code> method. <p>
 * @exception LoginException if the logout fails.
 * @return true in all cases since this <code>LoginModule</code>should not be ignored.
 */
public boolean logout() throws LoginException {
  ssl=null;
  sslUtils.setAppclientSsl(ssl);
  subject.getPrincipals().remove(userPrincipal);
  succeeded=false;
  succeeded=commitSucceeded;
  alias=null;
  userPrincipal=null;
  return true;
}

Fixed version (ground truth):
/** 
 * Logout the user. <p> This method removes the <code>PrincipalImpl</code> that was added by the <code>commit</code> method. <p>
 * @exception LoginException if the logout fails.
 * @return true in all cases since this <code>LoginModule</code>should not be ignored.
 */
public boolean logout() throws LoginException {
  ssl=null;
  sslUtils.setAppclientSsl(ssl);
  subject.getPrincipals().remove(userPrincipal);
  succeeded=false;
  commitSucceeded=false;
  alias=null;
  userPrincipal=null;
  return true;
}
Program: 30443
Project: 30443
Buggy source:
/** 
 * Return the hashCode computed from the password and realm name.
 * @return the hash code.
 */
public int hashCode(){
  return username.hashCode() + password.hashCode() + realm.hashCode();
}

Fixed version (ground truth):
/** 
 * Return the hashCode computed from the password and realm name.
 * @return the hash code.
 */
public int hashCode(){
  return username.hashCode() + Arrays.hashCode(password) + realm.hashCode();
}
Program: 30444
Project: 30444
Buggy source:
/** 
 * Compare two instances of the credential and return true if they are the same and false otherwise.
 * @param the object that this instance is being compared to.
 * @return true if the instances are equal, false otherwise
 */
public boolean equals(Object o){
  if (o instanceof PasswordCredential) {
    PasswordCredential pc=(PasswordCredential)o;
    if (pc.getUser().equals(username) && pc.getPassword().equals(password) && pc.getRealm().equals(realm)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compare two instances of the credential and return true if they are the same and false otherwise.
 * @param the object that this instance is being compared to.
 * @return true if the instances are equal, false otherwise
 */
public boolean equals(Object o){
  if (o instanceof PasswordCredential) {
    PasswordCredential pc=(PasswordCredential)o;
    if (pc.getUser().equals(username) && Arrays.equals(pc.getPassword(),password) && pc.getRealm().equals(realm)) {
      return true;
    }
  }
  return false;
}
Program: 30445
Project: 30445
Buggy source:
@Override public boolean equals(Object obj){
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  final StringNonce other=(StringNonce)obj;
  if (this.nonce != other.getNonce() && (this.nonce == null || !this.nonce.equals(other.getNonce()))) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  final StringNonce other=(StringNonce)obj;
  if (!this.nonce.equals(other.getNonce()) && (this.nonce == null || !this.nonce.equals(other.getNonce()))) {
    return false;
  }
  return true;
}
Program: 30446
Project: 30446
Buggy source:
/** 
 * Instantiates a Realm class of the given type and invokes its init()
 */
private static synchronized Realm doInstantiate(String name,String className,Properties props) throws BadRealmException {
  Habitat habitat=Globals.getDefaultHabitat();
  RealmsManager mgr=null;
  try {
    mgr=getRealmsManager();
    Class realmClass=null;
    Realm r=habitat.getComponent(Realm.class,name);
    if (r == null) {
      try {
        ClassLoaderHierarchy hierarchy=habitat.getComponent(ClassLoaderHierarchy.class);
        realmClass=hierarchy.getCommonClassLoader().loadClass(className);
        Object obj=realmClass.newInstance();
        r=(Realm)obj;
      }
 catch (      ClassNotFoundException ex) {
        realmClass=Class.forName(className);
        Object obj=realmClass.newInstance();
        r=(Realm)obj;
      }
    }
    if (r != null) {
      r.setName(name);
      r.init(props);
      if (mgr == null) {
        throw new BadRealmException("String_Node_Str");
      }
      _logger.log(Level.INFO,"String_Node_Str",new Object[]{name,className});
      return r;
    }
 else {
      throw new BadRealmException("String_Node_Str" + className);
    }
  }
 catch (  NoSuchRealmException ex) {
    throw new BadRealmException(ex);
  }
catch (  InstantiationException ex) {
    throw new BadRealmException(ex);
  }
catch (  IllegalAccessException ex) {
    throw new BadRealmException(ex);
  }
catch (  ClassNotFoundException ex) {
    throw new BadRealmException(ex);
  }
}

Fixed version (ground truth):
/** 
 * Instantiates a Realm class of the given type and invokes its init()
 */
private static synchronized Realm doInstantiate(String name,String className,Properties props) throws BadRealmException {
  Habitat habitat=Globals.getDefaultHabitat();
  RealmsManager mgr=null;
  try {
    mgr=getRealmsManager();
    Class realmClass=null;
    Realm r=habitat.getComponent(Realm.class,name);
    if (r == null) {
      try {
        ClassLoaderHierarchy hierarchy=habitat.getComponent(ClassLoaderHierarchy.class);
        realmClass=hierarchy.getCommonClassLoader().loadClass(className);
        Object obj=realmClass.newInstance();
        r=(Realm)obj;
      }
 catch (      ClassNotFoundException ex) {
        realmClass=Class.forName(className);
        Object obj=realmClass.newInstance();
        r=(Realm)obj;
      }
    }
    r.setName(name);
    r.init(props);
    if (mgr == null) {
      throw new BadRealmException("String_Node_Str");
    }
    _logger.log(Level.INFO,"String_Node_Str",new Object[]{name,className});
    return r;
  }
 catch (  NoSuchRealmException ex) {
    throw new BadRealmException(ex);
  }
catch (  InstantiationException ex) {
    throw new BadRealmException(ex);
  }
catch (  IllegalAccessException ex) {
    throw new BadRealmException(ex);
  }
catch (  ClassNotFoundException ex) {
    throw new BadRealmException(ex);
  }
}
Program: 30447
Project: 30447
Buggy source:
public static void createRealms(String defaultRealm,List<AuthRealm> realms,String configName){
  assert(realms != null);
  String goodRealm=null;
  for (  AuthRealm aRealm : realms) {
    String realmName=aRealm.getName();
    String realmClass=aRealm.getClassname();
    assert(realmName != null);
    assert(realmClass != null);
    try {
      List<Property> realmProps=aRealm.getProperty();
      Properties props=new Properties();
      for (      Property realmProp : realmProps) {
        props.setProperty(realmProp.getName(),realmProp.getValue());
      }
      Realm.instantiate(realmName,realmClass,props,configName);
      if (logger.isLoggable(Level.FINE)) {
        logger.fine("String_Node_Str" + realmName);
      }
      if (goodRealm == null) {
        goodRealm=realmName;
      }
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"String_Node_Str",realmName);
      logger.log(Level.WARNING,"String_Node_Str",e);
    }
  }
  if (goodRealm == null) {
    logger.severe("String_Node_Str");
  }
 else {
    try {
      Realm def=Realm.getInstance(defaultRealm);
      if (def == null) {
        defaultRealm=goodRealm;
      }
    }
 catch (    Exception e) {
      defaultRealm=goodRealm;
    }
    Realm.setDefaultRealm(defaultRealm);
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + defaultRealm);
    }
  }
}

Fixed version (ground truth):
public static void createRealms(String defaultRealm,List<AuthRealm> realms,String configName){
  assert(realms != null);
  String goodRealm=null;
  for (  AuthRealm aRealm : realms) {
    String realmName=aRealm.getName();
    String realmClass=aRealm.getClassname();
    assert(realmName != null);
    assert(realmClass != null);
    try {
      List<Property> realmProps=aRealm.getProperty();
      Properties props=new Properties();
      for (      Property realmProp : realmProps) {
        props.setProperty(realmProp.getName(),realmProp.getValue());
      }
      Realm.instantiate(realmName,realmClass,props,configName);
      if (logger.isLoggable(Level.FINE)) {
        logger.fine("String_Node_Str" + realmName);
      }
      if (goodRealm == null) {
        goodRealm=realmName;
      }
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"String_Node_Str",realmName);
      logger.log(Level.WARNING,"String_Node_Str",e);
    }
  }
  if (goodRealm == null) {
    logger.severe("String_Node_Str");
  }
 else {
    try {
      Realm def=Realm.getInstance(defaultRealm);
    }
 catch (    Exception e) {
      defaultRealm=goodRealm;
    }
    Realm.setDefaultRealm(defaultRealm);
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + defaultRealm);
    }
  }
}
Program: 30448
Project: 30448
Buggy source:
/** 
 * Load keyfile from config and populate internal cache.
 */
private void loadKeyFile() throws BadRealmException {
  String file=this.getProperty(PARAM_KEYFILE);
  _logger.fine("String_Node_Str" + file);
  File filePath=new File(file);
  if ((file != null) && !filePath.exists()) {
    try {
      if ((instanceRoot != null) && (filePath.getCanonicalPath().startsWith(instanceRoot))) {
        filePath.createNewFile();
      }
    }
 catch (    IOException ex) {
    }
  }
  BufferedReader input=null;
  try {
    if (Util.isEmbeddedServer()) {
      String embeddedFilePath=Util.writeConfigFileToTempDir(file).getAbsolutePath();
      this.setProperty(PARAM_KEYFILE,embeddedFilePath);
      input=new BufferedReader(new FileReader(embeddedFilePath));
    }
 else {
      input=new BufferedReader(new FileReader(file));
    }
    while (input.ready()) {
      String line=input.readLine();
      if (!line.startsWith(COMMENT) && line.indexOf(FIELD_SEP) > 0) {
        FileRealmUser ud=decodeUser(line,groupSizeMap);
        userTable.put(ud.getName(),ud);
      }
    }
  }
 catch (  Exception e) {
    _logger.log(Level.WARNING,"String_Node_Str",e);
    throw new BadRealmException(e.toString());
  }
 finally {
    if (input != null) {
      try {
        input.close();
      }
 catch (      Exception ex) {
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Load keyfile from config and populate internal cache.
 */
private void loadKeyFile() throws BadRealmException {
  String file=this.getProperty(PARAM_KEYFILE);
  _logger.fine("String_Node_Str" + file);
  File filePath=new File(file);
  if ((file != null) && !filePath.exists()) {
    try {
      if ((instanceRoot != null) && (filePath.getCanonicalPath().startsWith(instanceRoot))) {
        if (!filePath.createNewFile()) {
          throw new IOException();
        }
      }
    }
 catch (    IOException ex) {
    }
  }
  BufferedReader input=null;
  try {
    if (Util.isEmbeddedServer()) {
      String embeddedFilePath=Util.writeConfigFileToTempDir(file).getAbsolutePath();
      this.setProperty(PARAM_KEYFILE,embeddedFilePath);
      input=new BufferedReader(new FileReader(embeddedFilePath));
    }
 else {
      input=new BufferedReader(new FileReader(file));
    }
    while (input.ready()) {
      String line=input.readLine();
      if (!line.startsWith(COMMENT) && line.indexOf(FIELD_SEP) > 0) {
        FileRealmUser ud=decodeUser(line,groupSizeMap);
        userTable.put(ud.getName(),ud);
      }
    }
  }
 catch (  Exception e) {
    _logger.log(Level.WARNING,"String_Node_Str",e);
    throw new BadRealmException(e.toString());
  }
 finally {
    if (input != null) {
      try {
        input.close();
      }
 catch (      Exception ex) {
      }
    }
  }
}
Program: 30451
Project: 30451
Buggy source:
public static void addIndex(Config c,Habitat habitat,String name){
  habitat.addIndex(new ExistingSingletonInhabitant<Config>(c),Config.class.getName(),ServerEnvironment.DEFAULT_INSTANCE_NAME);
  ConfigBeanProxy dirref[]={c.getAdminListener(),c.getAdminService(),c.getAlertService(),c.getAvailabilityService(),c.getConnectorService(),c.getDiagnosticService(),c.getEjbContainer(),c.getGroupManagementService(),c.getHttpService(),c.getIiopService(),c.getJavaConfig(),c.getJmsService(),c.getLogService(),c.getManagementRules(),c.getMdbContainer(),c.getMonitoringService(),c.getNetworkConfig(),c.getSecurityService(),c.getThreadPools(),c.getTransactionService(),c.getWebContainer()};
  for (  ConfigBeanProxy cbp : dirref) {
    if (cbp != null) {
      habitat.addIndex(new ExistingSingletonInhabitant<ConfigBeanProxy>(cbp),ConfigSupport.getImpl(cbp).getProxyType().getName(),ServerEnvironment.DEFAULT_INSTANCE_NAME);
    }
  }
  for (  Container extension : c.getContainers()) {
    habitat.addIndex(new ExistingSingletonInhabitant<Container>(extension),ConfigSupport.getImpl(extension).getProxyType().getName(),ServerEnvironment.DEFAULT_INSTANCE_NAME);
  }
}

Fixed version (ground truth):
public static void addIndex(Config c,Habitat habitat,String name){
  habitat.addIndex(new ExistingSingletonInhabitant<Config>(c),Config.class.getName(),ServerEnvironment.DEFAULT_INSTANCE_NAME);
  ConfigBeanProxy dirref[]={c.getAdminService(),c.getAlertService(),c.getAvailabilityService(),c.getConnectorService(),c.getDiagnosticService(),c.getEjbContainer(),c.getGroupManagementService(),c.getHttpService(),c.getIiopService(),c.getJavaConfig(),c.getJmsService(),c.getLogService(),c.getManagementRules(),c.getMdbContainer(),c.getMonitoringService(),c.getNetworkConfig(),c.getSecurityService(),c.getThreadPools(),c.getTransactionService(),c.getWebContainer()};
  for (  ConfigBeanProxy cbp : dirref) {
    if (cbp != null) {
      habitat.addIndex(new ExistingSingletonInhabitant<ConfigBeanProxy>(cbp),ConfigSupport.getImpl(cbp).getProxyType().getName(),ServerEnvironment.DEFAULT_INSTANCE_NAME);
    }
  }
  for (  Container extension : c.getContainers()) {
    habitat.addIndex(new ExistingSingletonInhabitant<Container>(extension),ConfigSupport.getImpl(extension).getProxyType().getName(),ServerEnvironment.DEFAULT_INSTANCE_NAME);
  }
}
Program: 30454
Project: 30454
Buggy source:
public void init(){
  initialized=true;
  if (oname == null) {
    if (container instanceof StandardContext) {
      try {
        StandardContext ctx=(StandardContext)container;
        String path=ctx.getEncodedPath();
        if (path.equals("String_Node_Str")) {
          path="String_Node_Str";
        }
        oname=new ObjectName(ctx.getEngineName() + "String_Node_Str" + path+ "String_Node_Str"+ ctx.getParent().getName());
        controller=oname;
      }
 catch (      Exception e) {
        log.log(Level.SEVERE,"String_Node_Str",e);
      }
    }
  }
  if (container == null) {
  }
}

Fixed version (ground truth):
public void init(){
  initialized=true;
  if (oname == null) {
    if (container instanceof StandardContext) {
      try {
        StandardContext ctx=(StandardContext)container;
        String path=ctx.getEncodedPath();
        if (path.equals("String_Node_Str")) {
          path="String_Node_Str";
        }
        oname=new ObjectName(ctx.getEngineName() + "String_Node_Str" + path+ "String_Node_Str"+ ctx.getParent().getName());
        controller=oname;
      }
 catch (      Exception e) {
        log.log(Level.SEVERE,"String_Node_Str",e);
      }
    }
  }
}
Program: 30456
Project: 30456
Buggy source:
/** 
 * Return the random number generator instance we should use for generating session identifiers.  If there is no such generator currently defined, construct and seed a new one.
 */
public synchronized Random getRandom(){
  if (this.random == null) {
synchronized (this) {
      if (this.random == null) {
        long seed=System.currentTimeMillis();
        long t1=seed;
        char entropy[]=getEntropy().toCharArray();
        for (int i=0; i < entropy.length; i++) {
          long update=((byte)entropy[i]) << ((i % 8) * 8);
          seed^=update;
        }
        try {
          Class<?> clazz=Class.forName(randomClass);
          this.random=(Random)clazz.newInstance();
          this.random.setSeed(seed);
        }
 catch (        Exception e) {
          log.log(Level.SEVERE,sm.getString("String_Node_Str",randomClass),e);
          this.random=new java.util.Random();
          this.random.setSeed(seed);
        }
        long t2=System.currentTimeMillis();
        if ((t2 - t1) > 100)         if (log.isLoggable(Level.FINE)) {
          log.fine(sm.getString("String_Node_Str",randomClass) + "String_Node_Str" + (t2 - t1));
        }
      }
    }
  }
  return (this.random);
}

Fixed version (ground truth):
/** 
 * Return the random number generator instance we should use for generating session identifiers.  If there is no such generator currently defined, construct and seed a new one.
 */
public synchronized Random getRandom(){
  if (this.random == null) {
    long seed=System.currentTimeMillis();
    long t1=seed;
    char entropy[]=getEntropy().toCharArray();
    for (int i=0; i < entropy.length; i++) {
      long update=((byte)entropy[i]) << ((i % 8) * 8);
      seed^=update;
    }
    try {
      Class<?> clazz=Class.forName(randomClass);
      this.random=(Random)clazz.newInstance();
      this.random.setSeed(seed);
    }
 catch (    Exception e) {
      log.log(Level.SEVERE,sm.getString("String_Node_Str",randomClass),e);
      this.random=new java.util.Random();
      this.random.setSeed(seed);
    }
    long t2=System.currentTimeMillis();
    if ((t2 - t1) > 100)     if (log.isLoggable(Level.FINE)) {
      log.fine(sm.getString("String_Node_Str",randomClass) + "String_Node_Str" + (t2 - t1));
    }
  }
  return (this.random);
}
Program: 30457
Project: 30457
Buggy source:
/** 
 * Gracefully terminate the active use of the public methods of this component.  This method should be the last one called on a given instance of this component.
 * @exception LifecycleException if this component detects a fatal errorthat needs to be reported
 */
public void stop() throws LifecycleException {
  if (log.isLoggable(Level.FINE))   log.fine("String_Node_Str");
  if (!isStarted()) {
    if (log.isLoggable(Level.INFO)) {
      log.info(sm.getString("String_Node_Str"));
    }
    return;
  }
  lifecycle.fireLifecycleEvent(STOP_EVENT,null);
  setStarted(false);
  if (getStore() != null && saveOnRestart) {
    unload();
  }
 else {
    Session sessions[]=findSessions();
    for (int i=0; i < sessions.length; i++) {
      StandardSession session=(StandardSession)sessions[i];
      if (!session.isValid())       continue;
      session.expire();
    }
  }
  if (getStore() != null && getStore() instanceof Lifecycle)   ((Lifecycle)getStore()).stop();
  this.random=null;
  if (initialized)   destroy();
}

Fixed version (ground truth):
/** 
 * Gracefully terminate the active use of the public methods of this component.  This method should be the last one called on a given instance of this component.
 * @exception LifecycleException if this component detects a fatal errorthat needs to be reported
 */
public void stop() throws LifecycleException {
  if (log.isLoggable(Level.FINE))   log.fine("String_Node_Str");
  if (!isStarted()) {
    if (log.isLoggable(Level.INFO)) {
      log.info(sm.getString("String_Node_Str"));
    }
    return;
  }
  lifecycle.fireLifecycleEvent(STOP_EVENT,null);
  setStarted(false);
  if (getStore() != null && saveOnRestart) {
    unload();
  }
 else {
    Session sessions[]=findSessions();
    for (int i=0; i < sessions.length; i++) {
      StandardSession session=(StandardSession)sessions[i];
      if (!session.isValid())       continue;
      session.expire();
    }
  }
  if (getStore() != null && getStore() instanceof Lifecycle)   ((Lifecycle)getStore()).stop();
  resetRandom();
  if (initialized)   destroy();
}
Program: 30458
Project: 30458
Buggy source:
/** 
 * Gracefully terminate the active use of the public methods of this component.  This method should be the last one called on a given instance of this component.
 * @param isShutdown true if this manager is being stopped as part of adomain shutdown (as opposed to an undeployment), and false otherwise
 * @exception LifecycleException if this component detects a fatal errorthat needs to be reported
 */
public void stop(boolean isShutdown) throws LifecycleException {
  if (log.isLoggable(Level.FINE))   log.fine("String_Node_Str");
  if (!started)   throw new LifecycleException(sm.getString("String_Node_Str"));
  lifecycle.fireLifecycleEvent(STOP_EVENT,null);
  started=false;
  try {
    unload(false,isShutdown);
  }
 catch (  IOException e) {
    log.log(Level.SEVERE,sm.getString("String_Node_Str"),e);
  }
  Session sessions[]=findSessions();
  if (sessions != null) {
    for (    Session session : sessions) {
      if (!session.isValid()) {
        continue;
      }
      try {
        session.expire();
      }
 catch (      Throwable t) {
      }
 finally {
        session.recycle();
      }
    }
  }
  this.random=null;
  if (initialized) {
    destroy();
  }
}

Fixed version (ground truth):
/** 
 * Gracefully terminate the active use of the public methods of this component.  This method should be the last one called on a given instance of this component.
 * @param isShutdown true if this manager is being stopped as part of adomain shutdown (as opposed to an undeployment), and false otherwise
 * @exception LifecycleException if this component detects a fatal errorthat needs to be reported
 */
public void stop(boolean isShutdown) throws LifecycleException {
  if (log.isLoggable(Level.FINE))   log.fine("String_Node_Str");
  if (!started)   throw new LifecycleException(sm.getString("String_Node_Str"));
  lifecycle.fireLifecycleEvent(STOP_EVENT,null);
  started=false;
  try {
    unload(false,isShutdown);
  }
 catch (  IOException e) {
    log.log(Level.SEVERE,sm.getString("String_Node_Str"),e);
  }
  Session sessions[]=findSessions();
  if (sessions != null) {
    for (    Session session : sessions) {
      if (!session.isValid()) {
        continue;
      }
      try {
        session.expire();
      }
 catch (      Throwable t) {
      }
 finally {
        session.recycle();
      }
    }
  }
  resetRandom();
  if (initialized) {
    destroy();
  }
}
Program: 30462
Project: 30462
Buggy source:
/** 
 * Stops the given <tt>virtualServer</tt> and removes it from this <tt>WebContainer</tt>.
 * @param virtualServer the <tt>VirtualServer</tt> to be stoppedand removed
 * @throws GlassFishException if an error occurs during the stoppingor removal of the given <tt>virtualServer</tt>
 */
public void removeVirtualServer(VirtualServer virtualServer) throws GlassFishException {
  if (!initialized) {
    init();
  }
  engine.removeChild((Container)virtualServer);
}

Fixed version (ground truth):
/** 
 * Stops the given <tt>virtualServer</tt> and removes it from this <tt>WebContainer</tt>.
 * @param virtualServer the <tt>VirtualServer</tt> to be stoppedand removed
 * @throws GlassFishException if an error occurs during the stoppingor removal of the given <tt>virtualServer</tt>
 */
public void removeVirtualServer(VirtualServer virtualServer) throws GlassFishException {
  if (!initialized) {
    init();
  }
  if (virtualServer instanceof Container) {
    engine.removeChild((Container)virtualServer);
  }
 else   if (virtualServer instanceof VirtualServerFacade) {
    engine.removeChild(((VirtualServerFacade)virtualServer).getVirtualServer());
  }
}
Program: 30464
Project: 30464
Buggy source:
private void breakBlockAndStoreItems(final WorldServer w,final BlockPos pos,final List<ItemStack> items){
  w.setBlockToAir(pos);
  final AxisAlignedBB box=new AxisAlignedBB(pos.getX() - 0.2,pos.getY() - 0.2,pos.getZ() - 0.2,pos.getX() + 1.2,pos.getY() + 1.2,pos.getZ() + 1.2);
  for (  final Object ei : w.getEntitiesWithinAABB(EntityItem.class,box)) {
    if (ei instanceof EntityItem) {
      final EntityItem entityItem=(EntityItem)ei;
      this.storeEntityItem(entityItem);
    }
  }
  for (  final ItemStack snaggedItem : items) {
    final IAEItemStack overflow=this.storeItemStack(snaggedItem);
    this.spawnOverflow(overflow);
  }
}

Fixed version (ground truth):
private void breakBlockAndStoreItems(final WorldServer w,final BlockPos pos){
  w.destroyBlock(pos,true);
  final AxisAlignedBB box=new AxisAlignedBB(pos).grow(0.2);
  for (  final Object ei : w.getEntitiesWithinAABB(EntityItem.class,box)) {
    if (ei instanceof EntityItem) {
      final EntityItem entityItem=(EntityItem)ei;
      this.storeEntityItem(entityItem);
    }
  }
}