Program: 176759
Project: 176759
Buggy source:
/** 
 * Scan class and put metadata.
 * @param bits the bits
 * @param reader the reader
 * @param entityMetadataMap the entity metadata map
 * @param entityNameToClassMap the entity name to class map
 * @param persistence unit the persistence unit.
 * @throws IOException Signals that an I/O exception has occurred.
 */
private List<Class<?>> scanClassAndPutMetadata(InputStream bits,Reader reader,Map<Class<?>,EntityMetadata> entityMetadataMap,Map<String,Class<?>> entityNameToClassMap,String persistenceUnit,String client,Map<String,List<String>> clazzToPuMap) throws IOException {
  DataInputStream dstream=new DataInputStream(new BufferedInputStream(bits));
  ClassFile cf=null;
  String className=null;
  List<Class<?>> classes=new ArrayList<Class<?>>();
  try {
    cf=new ClassFile(dstream);
    className=cf.getName();
    List<String> annotations=new ArrayList<String>();
    reader.accumulateAnnotations(annotations,(AnnotationsAttribute)cf.getAttribute(AnnotationsAttribute.visibleTag));
    reader.accumulateAnnotations(annotations,(AnnotationsAttribute)cf.getAttribute(AnnotationsAttribute.invisibleTag));
    for (    String validAnn : reader.getValidAnnotations()) {
      if (annotations.contains(validAnn)) {
        Class<?> clazz=Class.forName(className);
        if (entityNameToClassMap.containsKey(clazz.getSimpleName()) && !entityNameToClassMap.get(clazz.getSimpleName()).getName().equals(clazz.getName())) {
          throw new MetamodelLoaderException("String_Node_Str" + entityNameToClassMap.get(clazz.getSimpleName()).getName() + "String_Node_Str"+ clazz.getName()+ "String_Node_Str"+ "String_Node_Str"+ persistenceUnit);
        }
        entityNameToClassMap.put(clazz.getSimpleName(),clazz);
        EntityMetadata metadata=entityMetadataMap.get(clazz);
        if (null == metadata) {
          log.debug("String_Node_Str" + clazz.getName());
synchronized (clazz) {
            if (null == metadata) {
              MetadataBuilder metadataBuilder=new MetadataBuilder(persistenceUnit,client);
              metadata=metadataBuilder.buildEntityMetadata(clazz);
              if (metadata != null) {
                entityMetadataMap.put(clazz,metadata);
                mapClazztoPu(clazz,persistenceUnit,clazzToPuMap);
              }
            }
          }
        }
        onValidateClientProperties(classes,clazz,persistenceUnit);
      }
    }
  }
 catch (  ClassNotFoundException e) {
    log.error("String_Node_Str" + className + "String_Node_Str");
  }
 finally {
    dstream.close();
    bits.close();
  }
  return classes;
}

Fixed version (ground truth):
/** 
 * Scan class and put metadata.
 * @param bits the bits
 * @param reader the reader
 * @param entityMetadataMap the entity metadata map
 * @param entityNameToClassMap the entity name to class map
 * @param persistence unit the persistence unit.
 * @throws IOException Signals that an I/O exception has occurred.
 */
private List<Class<?>> scanClassAndPutMetadata(InputStream bits,Reader reader,Map<Class<?>,EntityMetadata> entityMetadataMap,Map<String,Class<?>> entityNameToClassMap,String persistenceUnit,String client,Map<String,List<String>> clazzToPuMap) throws IOException {
  DataInputStream dstream=new DataInputStream(new BufferedInputStream(bits));
  ClassFile cf=null;
  String className=null;
  PersistenceUnitMetadata puMetadata=null;
  List<Class<?>> classes=new ArrayList<Class<?>>();
  try {
    cf=new ClassFile(dstream);
    className=cf.getName();
    List<String> annotations=new ArrayList<String>();
    reader.accumulateAnnotations(annotations,(AnnotationsAttribute)cf.getAttribute(AnnotationsAttribute.visibleTag));
    reader.accumulateAnnotations(annotations,(AnnotationsAttribute)cf.getAttribute(AnnotationsAttribute.invisibleTag));
    puMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(persistenceUnit);
    for (    String validAnn : reader.getValidAnnotations()) {
      if (annotations.contains(validAnn) && puMetadata != null) {
        Class<?> clazz=puMetadata.getClassLoader().loadClass(className);
        if (entityNameToClassMap.containsKey(clazz.getSimpleName()) && !entityNameToClassMap.get(clazz.getSimpleName()).getName().equals(clazz.getName())) {
          throw new MetamodelLoaderException("String_Node_Str" + entityNameToClassMap.get(clazz.getSimpleName()).getName() + "String_Node_Str"+ clazz.getName()+ "String_Node_Str"+ "String_Node_Str"+ persistenceUnit);
        }
        entityNameToClassMap.put(clazz.getSimpleName(),clazz);
        EntityMetadata metadata=entityMetadataMap.get(clazz);
        if (null == metadata) {
          log.debug("String_Node_Str" + clazz.getName());
synchronized (clazz) {
            if (null == metadata) {
              MetadataBuilder metadataBuilder=new MetadataBuilder(persistenceUnit,client);
              metadata=metadataBuilder.buildEntityMetadata(clazz);
              if (metadata != null) {
                entityMetadataMap.put(clazz,metadata);
                mapClazztoPu(clazz,persistenceUnit,clazzToPuMap);
              }
            }
          }
        }
        onValidateClientProperties(classes,clazz,persistenceUnit);
      }
    }
  }
 catch (  ClassNotFoundException e) {
    log.error("String_Node_Str" + className + "String_Node_Str");
  }
 finally {
    dstream.close();
    bits.close();
  }
  return classes;
}