Program: 63246
Project: 63246
Buggy source:
/** 
 * Build the class metadata for the class name using ASM to read the class byte codes.
 */
protected void buildClassMetadata(MetadataClass metadataClass,String className,boolean isLazy){
  ClassMetadataVisitor visitor=new ClassMetadataVisitor(metadataClass,isLazy);
  InputStream stream=null;
  try {
    String resourceString=className.replace('.','/') + "String_Node_Str";
    if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
      final String f_resourceString=resourceString;
      stream=AccessController.doPrivileged(new PrivilegedAction<InputStream>(){
        @Override public InputStream run(){
          return m_loader.getResourceAsStream(f_resourceString);
        }
      }
);
    }
 else {
      stream=m_loader.getResourceAsStream(resourceString);
    }
    ClassReader reader=new ClassReader(stream);
    Attribute[] attributes=new Attribute[0];
    reader.accept(visitor,attributes,ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
  }
 catch (  Exception exception) {
    metadataClass=new MetadataClass(this,className,false);
    if ((className.length() > 5) && className.substring(0,5).equals("String_Node_Str")) {
      try {
        Class reflectClass=Class.forName(className);
        if (reflectClass.getSuperclass() != null) {
          metadataClass.setSuperclassName(reflectClass.getSuperclass().getName());
        }
        for (        Class reflectInterface : reflectClass.getInterfaces()) {
          metadataClass.addInterface(reflectInterface.getName());
        }
      }
 catch (      Exception failed) {
        metadataClass.setIsAccessible(false);
      }
    }
 else {
      SessionLog log=getLogger().getSession() != null ? getLogger().getSession().getSessionLog() : AbstractSessionLog.getLog();
      if (log.shouldLog(SessionLog.SEVERE,SessionLog.METADATA)) {
        SessionLogEntry entry=new SessionLogEntry(getLogger().getSession(),SessionLog.SEVERE,SessionLog.METADATA,exception);
        entry.setMessage(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{className}));
        log.log(entry);
      }
      if (stream != null) {
        try {
          ClassReader reader=new EclipseLinkClassReader(stream);
          Attribute[] attributes=new Attribute[0];
          reader.accept(visitor,attributes,ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
        }
 catch (        Exception e) {
          if (log.shouldLog(SessionLog.SEVERE,SessionLog.METADATA)) {
            SessionLogEntry entry=new SessionLogEntry(getLogger().getSession(),SessionLog.SEVERE,SessionLog.METADATA,exception);
            entry.setMessage(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{className}));
            log.log(entry);
          }
          metadataClass.setIsAccessible(false);
          addMetadataClass(metadataClass);
        }
      }
 else {
        metadataClass.setIsAccessible(false);
        addMetadataClass(metadataClass);
      }
    }
  }
 finally {
    try {
      if (stream != null) {
        stream.close();
      }
    }
 catch (    IOException ignore) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Build the class metadata for the class name using ASM to read the class byte codes.
 */
protected void buildClassMetadata(MetadataClass metadataClass,String className,boolean isLazy){
  ClassMetadataVisitor visitor=new ClassMetadataVisitor(metadataClass,isLazy);
  InputStream stream=null;
  try {
    String resourceString=className.replace('.','/') + "String_Node_Str";
    if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
      final String f_resourceString=resourceString;
      stream=AccessController.doPrivileged(new PrivilegedAction<InputStream>(){
        @Override public InputStream run(){
          return m_loader.getResourceAsStream(f_resourceString);
        }
      }
);
    }
 else {
      stream=m_loader.getResourceAsStream(resourceString);
    }
    ClassReader reader=new ClassReader(stream);
    Attribute[] attributes=new Attribute[0];
    reader.accept(visitor,attributes,ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
  }
 catch (  IllegalArgumentException iae) {
    SessionLog log=getLogger().getSession() != null ? getLogger().getSession().getSessionLog() : AbstractSessionLog.getLog();
    if (log.shouldLog(SessionLog.SEVERE,SessionLog.METADATA)) {
      SessionLogEntry entry=new SessionLogEntry(getLogger().getSession(),SessionLog.SEVERE,SessionLog.METADATA,iae);
      entry.setMessage(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{className}));
      log.log(entry);
    }
    if (stream != null) {
      try {
        ClassReader reader=new EclipseLinkClassReader(stream);
        Attribute[] attributes=new Attribute[0];
        reader.accept(visitor,attributes,ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
      }
 catch (      Exception e) {
        if (log.shouldLog(SessionLog.SEVERE,SessionLog.METADATA)) {
          SessionLogEntry entry=new SessionLogEntry(getLogger().getSession(),SessionLog.SEVERE,SessionLog.METADATA,e);
          entry.setMessage(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{className}));
          log.log(entry);
        }
        addMetadataClass(getVirtualMetadataClass(className));
      }
    }
 else {
      addMetadataClass(getVirtualMetadataClass(className));
    }
  }
catch (  Exception exception) {
    SessionLog log=getLogger().getSession() != null ? getLogger().getSession().getSessionLog() : AbstractSessionLog.getLog();
    if (log.shouldLog(SessionLog.FINE,SessionLog.METADATA)) {
      log.logThrowable(SessionLog.FINE,SessionLog.METADATA,exception);
    }
    addMetadataClass(getVirtualMetadataClass(className));
  }
 finally {
    try {
      if (stream != null) {
        stream.close();
      }
    }
 catch (    IOException ignore) {
    }
  }
}