Program: 141654
Project: 141654
Buggy source:
private void handleSpringXml(String targetFilePath,ProcessItem processItem,InputStream springInput,ExportFileResource osgiResource,boolean convertToBP,boolean convertImports){
  File targetFile=new File(getTmpFolder() + PATH_SEPARATOR + targetFilePath);
  try {
    SAXReader saxReader=new SAXReader();
    saxReader.setStripWhitespaceText(false);
    Document document=saxReader.read(springInput);
    Element root=document.getRootElement();
    if (convertToBP) {
      if ("String_Node_Str".equals(root.getName())) {
        formatSchemaLocation(root,false,false);
        InputStream inputStream=new ByteArrayInputStream(root.asXML().getBytes());
        FilesUtils.copyFile(inputStream,targetFile);
        osgiResource.addResource(FileConstants.BLUEPRINT_FOLDER_NAME,targetFile.toURI().toURL());
        return;
      }
      String bpPrefix="String_Node_Str";
      int cnt=0;
      while (root.getNamespaceForPrefix(bpPrefix) != null) {
        bpPrefix="String_Node_Str" + (++cnt);
      }
      root.setQName(QName.get("String_Node_Str",bpPrefix,BLUEPRINT_NSURI));
    }
    Namespace springCamelNsp=Namespace.get("String_Node_Str",CAMEL_SPRING_NSURI);
    boolean addCamel=springCamelNsp.equals(root.getNamespaceForPrefix("String_Node_Str"));
    formatSchemaLocation(root,convertToBP,addCamel);
    for (Iterator<?> i=root.elementIterator("String_Node_Str"); i.hasNext(); ) {
      Element ip=(Element)i.next();
      Attribute resource=ip.attribute("String_Node_Str");
      URL path=dummyURL(resource.getValue());
      for (      ResourceDependencyModel resourceModel : RouteResourceUtil.getResourceDependencies(processItem)) {
        if (matches(path,resourceModel)) {
          IFile resourceFile=RouteResourceUtil.getSourceFile(resourceModel.getItem());
          String cpUrl=adaptedClassPathUrl(resourceModel,convertImports);
          handleSpringXml(cpUrl,processItem,resourceFile.getContents(),osgiResource,convertImports,convertImports);
          resource.setValue(IMPORT_RESOURCE_PREFIX + cpUrl);
        }
      }
      if (convertImports) {
        i.remove();
      }
    }
    if (CONVERT_CAMEL_CONTEXT) {
      if (CONVERT_CAMEL_CONTEXT_ALL) {
        moveNamespace(root,CAMEL_SPRING_NSURI,CAMEL_BLUEPRINT_NSURI);
      }
 else {
        Namespace blueprintCamelNsp=Namespace.get("String_Node_Str",CAMEL_BLUEPRINT_NSURI);
        moveNamespace(root,springCamelNsp,blueprintCamelNsp);
        Namespace springCamelDefNsp=Namespace.get(CAMEL_SPRING_NSURI);
        Namespace blueprintCamelDefNsp=Namespace.get(CAMEL_BLUEPRINT_NSURI);
        for (Iterator<?> i=root.elementIterator("String_Node_Str"); i.hasNext(); ) {
          Element cc=(Element)i.next();
          if (springCamelDefNsp.equals(cc.getNamespace())) {
            moveNamespace(cc,springCamelDefNsp,blueprintCamelDefNsp);
          }
        }
      }
    }
    InputStream inputStream=new ByteArrayInputStream(root.asXML().getBytes());
    FilesUtils.copyFile(inputStream,targetFile);
    osgiResource.addResource(adaptedResourceFolderName(targetFilePath,convertToBP),targetFile.toURI().toURL());
  }
 catch (  Exception e) {
    Logger.getAnonymousLogger().log(Level.WARNING,"String_Node_Str",e);
  }
 finally {
    try {
      springInput.close();
    }
 catch (    IOException e) {
      Logger.getAnonymousLogger().log(Level.WARNING,"String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void handleSpringXml(String targetFilePath,ProcessItem processItem,InputStream springInput,ExportFileResource osgiResource,boolean convertToBP,boolean convertImports){
  File targetFile=new File(getTmpFolder() + PATH_SEPARATOR + targetFilePath);
  try {
    SAXReader saxReader=new SAXReader();
    saxReader.setStripWhitespaceText(false);
    Document document=saxReader.read(springInput);
    Element root=document.getRootElement();
    if (convertToBP) {
      if ("String_Node_Str".equals(root.getName())) {
        formatSchemaLocation(root,false,false);
        InputStream inputStream=new ByteArrayInputStream(root.asXML().getBytes());
        FilesUtils.copyFile(inputStream,targetFile);
        osgiResource.addResource(FileConstants.BLUEPRINT_FOLDER_NAME,targetFile.toURI().toURL());
        return;
      }
      String bpPrefix="String_Node_Str";
      int cnt=0;
      while (root.getNamespaceForPrefix(bpPrefix) != null) {
        bpPrefix="String_Node_Str" + (++cnt);
      }
      root.setQName(QName.get("String_Node_Str",bpPrefix,BLUEPRINT_NSURI));
    }
    Namespace springCamelNsp=Namespace.get("String_Node_Str",CAMEL_SPRING_NSURI);
    boolean addCamel=springCamelNsp.equals(root.getNamespaceForPrefix("String_Node_Str"));
    formatSchemaLocation(root,convertToBP,addCamel);
    for (Iterator<?> i=root.elementIterator("String_Node_Str"); i.hasNext(); ) {
      Element ip=(Element)i.next();
      Attribute resource=ip.attribute("String_Node_Str");
      URL path=dummyURL(resource.getValue());
      for (      ResourceDependencyModel resourceModel : RouteResourceUtil.getResourceDependencies(processItem)) {
        if (matches(path,resourceModel)) {
          IFile resourceFile=RouteResourceUtil.getSourceFile(resourceModel.getItem());
          String cpUrl=adaptedClassPathUrl(resourceModel,convertImports);
          handleSpringXml(cpUrl,processItem,resourceFile.getContents(),osgiResource,convertImports,convertImports);
          resource.setValue(IMPORT_RESOURCE_PREFIX + cpUrl);
        }
      }
      if (convertImports) {
        i.remove();
      }
    }
    if (CONVERT_CAMEL_CONTEXT) {
      if (CONVERT_CAMEL_CONTEXT_ALL) {
        moveNamespace(root,CAMEL_SPRING_NSURI,CAMEL_BLUEPRINT_NSURI);
      }
 else {
        Namespace blueprintCamelNsp=Namespace.get("String_Node_Str",CAMEL_BLUEPRINT_NSURI);
        moveNamespace(root,springCamelNsp,blueprintCamelNsp);
        if (springCamelNsp.equals(root.getNamespaceForPrefix("String_Node_Str"))) {
          root.remove(springCamelNsp);
          root.add(blueprintCamelNsp);
        }
        Namespace springCamelDefNsp=Namespace.get(CAMEL_SPRING_NSURI);
        Namespace blueprintCamelDefNsp=Namespace.get(CAMEL_BLUEPRINT_NSURI);
        for (Iterator<?> i=root.elementIterator("String_Node_Str"); i.hasNext(); ) {
          Element cc=(Element)i.next();
          if (springCamelDefNsp.equals(cc.getNamespace())) {
            moveNamespace(cc,springCamelDefNsp,blueprintCamelDefNsp);
          }
        }
      }
    }
    InputStream inputStream=new ByteArrayInputStream(root.asXML().getBytes());
    FilesUtils.copyFile(inputStream,targetFile);
    osgiResource.addResource(adaptedResourceFolderName(targetFilePath,convertToBP),targetFile.toURI().toURL());
  }
 catch (  Exception e) {
    Logger.getAnonymousLogger().log(Level.WARNING,"String_Node_Str",e);
  }
 finally {
    try {
      springInput.close();
    }
 catch (    IOException e) {
      Logger.getAnonymousLogger().log(Level.WARNING,"String_Node_Str",e);
    }
  }
}