Program: 177164
Project: 177164
Buggy source:
/** 
 * Scans the Enunciate classpath for classes to be imported.
 * @return The classes to be imported, associated with their source file if it was found.
 */
protected Map<String,File> scanForClassesToImport() throws IOException {
  final Map<String,File> classes2sources=new HashMap<String,File>();
  File tempSourcesDir=createTempDir();
  List<String> classpath=new ArrayList<String>(Arrays.asList(getEnunciateClasspath().split(File.pathSeparator)));
  for (  String pathItem : classpath) {
    final File pathFile=new File(pathItem);
    if (pathFile.exists()) {
      if (pathFile.isDirectory()) {
        final Map<String,File> foundClasses2Sources=new HashMap<String,File>();
        visitFiles(pathFile,null,new FileVisitor(){
          public void visit(          File file){
            String path=pathFile.toURI().relativize(file.toURI()).getPath();
            if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 6).replace('/','.').replace('$','.');
              debug("String_Node_Str",classname,file);
              foundClasses2Sources.put(classname,foundClasses2Sources.get(classname));
            }
 else             if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 5).replace('/','.');
              debug("String_Node_Str",classname,file);
              foundClasses2Sources.put(classname,pathFile);
            }
 else             if ("String_Node_Str".equals(path)) {
              debug("String_Node_Str",file);
              try {
                FileInputStream autoImportList=new FileInputStream(file);
                Set<String> autoImports=readAutoImports(autoImportList);
                autoImportList.close();
                for (                String autoImport : autoImports) {
                  classes2sources.put(autoImport,classes2sources.get(autoImport));
                }
              }
 catch (              IOException e) {
                warn("String_Node_Str",file,e.getMessage());
              }
            }
          }
        }
);
        copyImportedClasses(foundClasses2Sources,classes2sources);
      }
 else {
        final Map<String,File> foundClasses2Sources=new HashMap<String,File>();
        JarFile jarFile;
        try {
          jarFile=new JarFile(pathFile);
        }
 catch (        IOException e) {
          warn("String_Node_Str",pathFile);
          continue;
        }
        Manifest manifest=jarFile.getManifest();
        if (manifest != null && manifest.getMainAttributes() != null) {
          String specTitle=manifest.getMainAttributes().getValue(Attributes.Name.SPECIFICATION_TITLE);
          if ("String_Node_Str".equalsIgnoreCase(String.valueOf(specTitle).trim())) {
            debug("String_Node_Str",pathFile);
            continue;
          }
        }
        Enumeration<JarEntry> entries=jarFile.entries();
        while (entries.hasMoreElements()) {
          JarEntry entry=entries.nextElement();
          if (!entry.isDirectory()) {
            String path=entry.getName();
            if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 6).replace('/','.').replace('$','.');
              debug("String_Node_Str",classname,pathFile);
              foundClasses2Sources.put(classname,foundClasses2Sources.get(classname));
            }
 else             if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 5).replace('/','.');
              File sourcesFile=new File(tempSourcesDir,path);
              debug("String_Node_Str",classname,pathFile,sourcesFile);
              try {
                InputStream in=jarFile.getInputStream(entry);
                sourcesFile.getParentFile().mkdirs();
                FileOutputStream out=new FileOutputStream(sourcesFile);
                byte[] buffer=new byte[1024 * 2];
                int len;
                while ((len=in.read(buffer)) > 0) {
                  out.write(buffer,0,len);
                }
                out.flush();
                out.close();
                in.close();
                foundClasses2Sources.put(classname,sourcesFile);
              }
 catch (              IOException e) {
                warn("String_Node_Str",sourcesFile,e.getMessage());
              }
            }
 else             if ("String_Node_Str".equals(path)) {
              debug("String_Node_Str",pathFile);
              try {
                InputStream in=jarFile.getInputStream(entry);
                Set<String> autoImports=readAutoImports(in);
                in.close();
                for (                String autoImport : autoImports) {
                  classes2sources.put(autoImport,classes2sources.get(autoImport));
                }
              }
 catch (              IOException e) {
                warn("String_Node_Str",pathFile,e.getMessage());
              }
            }
          }
        }
        copyImportedClasses(foundClasses2Sources,classes2sources);
      }
    }
 else {
      debug("String_Node_Str",pathItem);
    }
  }
  if (this.config != null && this.config.getAPIImports() != null && !this.config.getAPIImports().isEmpty()) {
    AntPatternMatcher matcher=new AntPatternMatcher();
    matcher.setPathSeparator("String_Node_Str");
    for (    APIImport apiImport : this.config.getAPIImports()) {
      if (!matcher.isPattern(apiImport.getPattern()) && !classes2sources.containsKey(apiImport.getPattern())) {
        warn("String_Node_Str",apiImport.getPattern());
        classes2sources.put(apiImport.getPattern(),null);
      }
    }
  }
  return classes2sources;
}

Fixed version (ground truth):
/** 
 * Scans the Enunciate classpath for classes to be imported.
 * @return The classes to be imported, associated with their source file if it was found.
 */
protected Map<String,File> scanForClassesToImport() throws IOException {
  final Map<String,File> classes2sources=new HashMap<String,File>();
  File tempSourcesDir=createTempDir();
  List<String> classpath=new ArrayList<String>(Arrays.asList(getEnunciateClasspath().split(File.pathSeparator)));
  for (  String pathItem : classpath) {
    final File pathFile=new File(pathItem);
    final Map<String,File> foundClasses2Sources=new HashMap<String,File>();
    if (pathFile.exists()) {
      if (pathFile.isDirectory()) {
        visitFiles(pathFile,null,new FileVisitor(){
          public void visit(          File file){
            String path=pathFile.toURI().relativize(file.toURI()).getPath();
            if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 6).replace('/','.').replace('$','.');
              debug("String_Node_Str",classname,file);
              foundClasses2Sources.put(classname,foundClasses2Sources.get(classname));
            }
 else             if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 5).replace('/','.');
              debug("String_Node_Str",classname,file);
              foundClasses2Sources.put(classname,pathFile);
            }
 else             if ("String_Node_Str".equals(path)) {
              debug("String_Node_Str",file);
              try {
                FileInputStream autoImportList=new FileInputStream(file);
                Set<String> autoImports=readAutoImports(autoImportList);
                autoImportList.close();
                for (                String autoImport : autoImports) {
                  classes2sources.put(autoImport,classes2sources.get(autoImport));
                }
              }
 catch (              IOException e) {
                warn("String_Node_Str",file,e.getMessage());
              }
            }
          }
        }
);
      }
 else {
        JarFile jarFile;
        try {
          jarFile=new JarFile(pathFile);
        }
 catch (        IOException e) {
          warn("String_Node_Str",pathFile);
          continue;
        }
        Manifest manifest=jarFile.getManifest();
        if (manifest != null && manifest.getMainAttributes() != null) {
          String specTitle=manifest.getMainAttributes().getValue(Attributes.Name.SPECIFICATION_TITLE);
          if ("String_Node_Str".equalsIgnoreCase(String.valueOf(specTitle).trim())) {
            debug("String_Node_Str",pathFile);
            continue;
          }
        }
        Enumeration<JarEntry> entries=jarFile.entries();
        while (entries.hasMoreElements()) {
          JarEntry entry=entries.nextElement();
          if (!entry.isDirectory()) {
            String path=entry.getName();
            if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 6).replace('/','.').replace('$','.');
              debug("String_Node_Str",classname,pathFile);
              foundClasses2Sources.put(classname,foundClasses2Sources.get(classname));
            }
 else             if (path.endsWith("String_Node_Str")) {
              String classname=path.substring(0,path.length() - 5).replace('/','.');
              File sourcesFile=new File(tempSourcesDir,path);
              debug("String_Node_Str",classname,pathFile,sourcesFile);
              try {
                InputStream in=jarFile.getInputStream(entry);
                sourcesFile.getParentFile().mkdirs();
                FileOutputStream out=new FileOutputStream(sourcesFile);
                byte[] buffer=new byte[1024 * 2];
                int len;
                while ((len=in.read(buffer)) > 0) {
                  out.write(buffer,0,len);
                }
                out.flush();
                out.close();
                in.close();
                foundClasses2Sources.put(classname,sourcesFile);
              }
 catch (              IOException e) {
                warn("String_Node_Str",sourcesFile,e.getMessage());
              }
            }
 else             if ("String_Node_Str".equals(path)) {
              debug("String_Node_Str",pathFile);
              try {
                InputStream in=jarFile.getInputStream(entry);
                Set<String> autoImports=readAutoImports(in);
                in.close();
                for (                String autoImport : autoImports) {
                  classes2sources.put(autoImport,classes2sources.get(autoImport));
                }
              }
 catch (              IOException e) {
                warn("String_Node_Str",pathFile,e.getMessage());
              }
            }
          }
        }
      }
    }
 else {
      debug("String_Node_Str",pathItem);
    }
    copyImportedClasses(foundClasses2Sources,classes2sources);
    for (    DeploymentModule module : this.config.getAllModules()) {
      if (module instanceof EnunciateClasspathListener) {
        ((EnunciateClasspathListener)module).onClassesFound(foundClasses2Sources.keySet());
      }
    }
  }
  if (this.config != null && this.config.getAPIImports() != null && !this.config.getAPIImports().isEmpty()) {
    AntPatternMatcher matcher=new AntPatternMatcher();
    matcher.setPathSeparator("String_Node_Str");
    for (    APIImport apiImport : this.config.getAPIImports()) {
      if (!matcher.isPattern(apiImport.getPattern()) && !classes2sources.containsKey(apiImport.getPattern())) {
        warn("String_Node_Str",apiImport.getPattern());
        classes2sources.put(apiImport.getPattern(),null);
      }
    }
  }
  return classes2sources;
}