Program: 30053
Project: 30053
Buggy source:
/** 
 * CreateEMFs and save them in persistence
 * @param context
 */
private void createEMFs(DeploymentContext context){
  Application application=context.getModuleMetaData(Application.class);
  Set<BundleDescriptor> bundles=application.getBundleDescriptors();
  boolean hasScopedResource=false;
  final List<PersistenceUnitDescriptor> referencedPus=new ArrayList<PersistenceUnitDescriptor>();
  for (  BundleDescriptor bundle : bundles) {
    Collection<? extends PersistenceUnitDescriptor> pusReferencedFromBundle=bundle.findReferencedPUs();
    for (    PersistenceUnitDescriptor pud : pusReferencedFromBundle) {
      referencedPus.add(pud);
      if (hasScopedResource(pud)) {
        hasScopedResource=true;
      }
    }
  }
  if (hasScopedResource) {
    connectorRuntime.registerDataSourceDefinitions(application);
  }
  PersistenceUnitDescriptorIterator pudIterator=new PersistenceUnitDescriptorIterator(){
    @Override void visitPUD(    PersistenceUnitDescriptor pud,    DeploymentContext context){
      if (referencedPus.contains(pud)) {
        boolean isDas=isDas();
        boolean weavingEnabled=Boolean.valueOf(sc.getArguments().getProperty("String_Node_Str","String_Node_Str"));
        ProviderContainerContractInfo providerContainerContractInfo=weavingEnabled ? new ServerProviderContainerContractInfo(context,connectorRuntime,isDas) : new EmbeddedProviderContainerContractInfo(context,connectorRuntime,isDas);
        PersistenceUnitLoader puLoader=new PersistenceUnitLoader(pud,providerContainerContractInfo);
        context.addTransientAppMetaData(getUniquePuIdentifier(pud),puLoader);
      }
    }
  }
;
  pudIterator.iteratePUDs(context);
}

Fixed version (ground truth):
/** 
 * CreateEMFs and save them in persistence
 * @param context
 */
private void createEMFs(DeploymentContext context){
  Application application=context.getModuleMetaData(Application.class);
  Set<BundleDescriptor> bundles=application.getBundleDescriptors();
  boolean hasScopedResource=false;
  final List<PersistenceUnitDescriptor> referencedPus=new ArrayList<PersistenceUnitDescriptor>();
  for (  BundleDescriptor bundle : bundles) {
    Collection<? extends PersistenceUnitDescriptor> pusReferencedFromBundle=bundle.findReferencedPUs();
    for (    PersistenceUnitDescriptor pud : pusReferencedFromBundle) {
      referencedPus.add(pud);
      if (hasScopedResource(pud)) {
        hasScopedResource=true;
      }
    }
  }
  if (hasScopedResource) {
    connectorRuntime.registerDataSourceDefinitions(application);
  }
  PersistenceUnitDescriptorIterator pudIterator=new PersistenceUnitDescriptorIterator(){
    @Override void visitPUD(    PersistenceUnitDescriptor pud,    DeploymentContext context){
      if (referencedPus.contains(pud)) {
        boolean isDas=isDas();
        boolean weavingEnabled=Boolean.valueOf(sc.getArguments().getProperty("String_Node_Str","String_Node_Str"));
        ProviderContainerContractInfo providerContainerContractInfo=weavingEnabled ? new ServerProviderContainerContractInfo(context,connectorRuntime,isDas) : new EmbeddedProviderContainerContractInfo(context,connectorRuntime,isDas);
        try {
          ((ExtendedDeploymentContext)context).prepareScratchDirs();
        }
 catch (        IOException e) {
          throw new RuntimeException(e);
        }
        PersistenceUnitLoader puLoader=new PersistenceUnitLoader(pud,providerContainerContractInfo);
        context.addTransientAppMetaData(getUniquePuIdentifier(pud),puLoader);
      }
    }
  }
;
  pudIterator.iteratePUDs(context);
}