Program: 176549
Project: 176549
Buggy source:
/** 
 * Load entity metadata.
 * @param persistenceUnit the persistence unit
 */
private void loadEntityMetadata(String persistenceUnit){
  if (persistenceUnit == null) {
    throw new IllegalArgumentException("String_Node_Str" + persistenceUnit);
  }
  KunderaMetadata kunderaMetadata=KunderaMetadata.INSTANCE;
  Map<String,PersistenceUnitMetadata> persistentUnitMetadataMap=kunderaMetadata.getApplicationMetadata().getPersistenceUnitMetadataMap();
  List<String> classesToScan;
  URL[] resources=null;
  String client=null;
  List<URL> managedURLs=null;
  if (persistentUnitMetadataMap == null || persistentUnitMetadataMap.isEmpty()) {
    log.error("String_Node_Str" + persistenceUnit + "String_Node_Str");
    throw new MetamodelLoaderException("String_Node_Str" + persistenceUnit + "String_Node_Str");
  }
 else {
    PersistenceUnitMetadata puMetadata=persistentUnitMetadataMap.get(persistenceUnit);
    classesToScan=puMetadata.getManagedClassNames();
    managedURLs=puMetadata.getManagedURLs();
    Map<String,Object> externalProperties=KunderaCoreUtils.getExternalProperties(persistenceUnit,externalProperyMap,persistenceUnits);
    client=externalProperties != null ? (String)externalProperties.get(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
    if (client == null) {
      client=puMetadata.getClient();
    }
  }
  Reader reader;
  ApplicationMetadata appMetadata=kunderaMetadata.getApplicationMetadata();
  if (classesToScan == null || classesToScan.isEmpty()) {
    log.info("String_Node_Str" + persistenceUnit + "String_Node_Str");
    if (appMetadata.getMetamodelMap().get(persistenceUnit) != null) {
      log.info("String_Node_Str");
      return;
    }
    reader=new ClasspathReader();
  }
 else {
    reader=new ClasspathReader(classesToScan);
  }
  URL[] managedClasses=reader.findResources();
  if (managedClasses != null) {
    List<URL> managedResources=Arrays.asList(managedClasses);
    managedURLs.addAll(managedResources);
  }
  if (managedURLs != null) {
    resources=managedURLs.toArray(new URL[]{});
  }
  reader.addValidAnnotations(Entity.class.getName());
  Metamodel metamodel=appMetadata.getMetamodel(persistenceUnit);
  if (metamodel == null) {
    metamodel=new MetamodelImpl();
  }
  Map<String,EntityMetadata> entityMetadataMap=((MetamodelImpl)metamodel).getEntityMetadataMap();
  Map<String,Class<?>> entityNameToClassMap=((MetamodelImpl)metamodel).getEntityNameToClassMap();
  Map<String,List<String>> puToClazzMap=new HashMap<String,List<String>>();
  Map<String,IdDiscriptor> entityNameToKeyDiscriptorMap=new HashMap<String,IdDiscriptor>();
  List<Class<?>> classes=new ArrayList<Class<?>>();
  if (resources != null) {
    for (    URL resource : resources) {
      try {
        ResourceIterator itr=reader.getResourceIterator(resource,reader.getFilter());
        InputStream is=null;
        while ((is=itr.next()) != null) {
          classes.addAll(scanClassAndPutMetadata(is,reader,entityMetadataMap,entityNameToClassMap,persistenceUnit,client,puToClazzMap,entityNameToKeyDiscriptorMap));
        }
      }
 catch (      IOException e) {
        log.error("String_Node_Str",e);
        throw new MetamodelLoaderException("String_Node_Str");
      }
    }
  }
  ((MetamodelImpl)metamodel).setEntityMetadataMap(entityMetadataMap);
  appMetadata.getMetamodelMap().put(persistenceUnit,metamodel);
  appMetadata.setClazzToPuMap(puToClazzMap);
  ((MetamodelImpl)metamodel).addKeyValues(entityNameToKeyDiscriptorMap);
  ((MetamodelImpl)metamodel).assignEmbeddables(KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(persistenceUnit).getEmbeddables());
  ((MetamodelImpl)metamodel).assignManagedTypes(KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(persistenceUnit).getManagedTypes());
  ((MetamodelImpl)metamodel).assignMappedSuperClass(KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(persistenceUnit).getMappedSuperClassTypes());
  validateEntityForClientSpecificProperty(classes,persistenceUnit);
}

Fixed version (ground truth):
/** 
 * Load entity metadata.
 * @param persistenceUnit the persistence unit
 */
private void loadEntityMetadata(String persistenceUnit){
  if (persistenceUnit == null) {
    throw new IllegalArgumentException("String_Node_Str" + persistenceUnit);
  }
  KunderaMetadata kunderaMetadata=KunderaMetadata.INSTANCE;
  Map<String,PersistenceUnitMetadata> persistentUnitMetadataMap=kunderaMetadata.getApplicationMetadata().getPersistenceUnitMetadataMap();
  List<String> classesToScan;
  URL[] resources=null;
  String client=null;
  List<URL> managedURLs=null;
  if (persistentUnitMetadataMap == null || persistentUnitMetadataMap.isEmpty()) {
    log.error("String_Node_Str" + persistenceUnit + "String_Node_Str");
    throw new MetamodelLoaderException("String_Node_Str" + persistenceUnit + "String_Node_Str");
  }
 else {
    PersistenceUnitMetadata puMetadata=persistentUnitMetadataMap.get(persistenceUnit);
    classesToScan=puMetadata.getManagedClassNames();
    managedURLs=puMetadata.getManagedURLs();
    Map<String,Object> externalProperties=KunderaCoreUtils.getExternalProperties(persistenceUnit,externalPropertyMap,persistenceUnits);
    client=externalProperties != null ? (String)externalProperties.get(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
    if (client == null) {
      client=puMetadata.getClient();
    }
  }
  Reader reader;
  ApplicationMetadata appMetadata=kunderaMetadata.getApplicationMetadata();
  if (classesToScan == null || classesToScan.isEmpty()) {
    log.info("String_Node_Str" + persistenceUnit + "String_Node_Str");
    if (appMetadata.getMetamodelMap().get(persistenceUnit) != null) {
      log.info("String_Node_Str");
      return;
    }
    reader=new ClasspathReader();
  }
 else {
    reader=new ClasspathReader(classesToScan);
  }
  URL[] managedClasses=reader.findResources();
  if (managedClasses != null) {
    List<URL> managedResources=Arrays.asList(managedClasses);
    managedURLs.addAll(managedResources);
  }
  if (managedURLs != null) {
    resources=managedURLs.toArray(new URL[]{});
  }
  reader.addValidAnnotations(Entity.class.getName());
  Metamodel metamodel=appMetadata.getMetamodel(persistenceUnit);
  if (metamodel == null) {
    metamodel=new MetamodelImpl();
  }
  Map<String,EntityMetadata> entityMetadataMap=((MetamodelImpl)metamodel).getEntityMetadataMap();
  Map<String,Class<?>> entityNameToClassMap=((MetamodelImpl)metamodel).getEntityNameToClassMap();
  Map<String,List<String>> puToClazzMap=new HashMap<String,List<String>>();
  Map<String,IdDiscriptor> entityNameToKeyDiscriptorMap=new HashMap<String,IdDiscriptor>();
  List<Class<?>> classes=new ArrayList<Class<?>>();
  if (resources != null) {
    for (    URL resource : resources) {
      try {
        ResourceIterator itr=reader.getResourceIterator(resource,reader.getFilter());
        InputStream is=null;
        while ((is=itr.next()) != null) {
          classes.addAll(scanClassAndPutMetadata(is,reader,entityMetadataMap,entityNameToClassMap,persistenceUnit,client,puToClazzMap,entityNameToKeyDiscriptorMap));
        }
      }
 catch (      IOException e) {
        log.error("String_Node_Str",e);
        throw new MetamodelLoaderException("String_Node_Str");
      }
    }
  }
  ((MetamodelImpl)metamodel).setEntityMetadataMap(entityMetadataMap);
  appMetadata.getMetamodelMap().put(persistenceUnit,metamodel);
  appMetadata.setClazzToPuMap(puToClazzMap);
  ((MetamodelImpl)metamodel).addKeyValues(entityNameToKeyDiscriptorMap);
  ((MetamodelImpl)metamodel).assignEmbeddables(KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(persistenceUnit).getEmbeddables());
  ((MetamodelImpl)metamodel).assignManagedTypes(KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(persistenceUnit).getManagedTypes());
  ((MetamodelImpl)metamodel).assignMappedSuperClass(KunderaMetadata.INSTANCE.getApplicationMetadata().getMetaModelBuilder(persistenceUnit).getMappedSuperClassTypes());
  validateEntityForClientSpecificProperty(classes,persistenceUnit);
}