Program: 101999
Project: 101999
Buggy source:
/** 
 * This method is called by   {@link #execute(IProgressMonitor,List)} to process the {@link IWebServiceResource} instances andmake sure that all XSDs are located in the workspace. This includes: <ul> <li>copying into the workspace all XSDs that are outside of the workspace</li> <li>creating XSD files in the workspace for all XSD definitions within the WSDL files</li> </ul> <p> Note that when doing so, it may be required to add to the <code>schemaLocation</code> within the XSDs. </p>
 * @param monitor
 * @param problems
 * @return the set of {@link XSDSchema} instances that should be used by the generator
 * @since 4.2
 */
protected Set doProcessXsds(final IProgressMonitor monitor,final List problems){
  final Set results=new HashSet();
  final Collection xsdDestinations=this.builder.getXsdDestinations();
  final Iterator iter=xsdDestinations.iterator();
  Set newXsdFiles=new HashSet();
  Set destProjectRelativePaths=getDestProjectRelativePaths(xsdDestinations);
  while (iter.hasNext()) {
    final IWebServiceXsdResource xsdDest=(IWebServiceXsdResource)iter.next();
    if (xsdDest == null || xsdDest.getDestinationPath() == null) {
      continue;
    }
    final IPath destFilePath=xsdDest.getDestinationPath();
    final IPath destProjectRelativePath=destFilePath.removeFirstSegments(1);
    final IPath destPath=destProjectRelativePath.removeLastSegments(1);
    final IPath absoluteProjectPath=builder.getParentResource().getLocation();
    final IPath absoluteDestPath=absoluteProjectPath.append(destPath);
    final File pathFile=new File(absoluteDestPath.toOSString());
    pathFile.mkdirs();
    try {
      builder.getParentResource().refreshLocal(IResource.DEPTH_INFINITE,null);
    }
 catch (    CoreException err1) {
      final Object[] params=new Object[]{builder.getParentResource().getName(),err1.getMessage()};
      final String msg=WebServicePlugin.Util.getString("String_Node_Str",params);
      final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,null);
      problems.add(status);
    }
    final XSDSchema schema=xsdDest.getSchema();
    final IFile file=((IContainer)builder.getParentResource()).getFile(destProjectRelativePath);
    if (file == null) {
      final Object[] params=new Object[]{xsdDest.getOriginalPath(),destProjectRelativePath};
      final String msg=WebServicePlugin.Util.getString("String_Node_Str",params);
      final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,null);
      problems.add(status);
    }
 else {
      File tempFile=null;
      try {
        OutputStream stream=null;
        InputStream inputStream=null;
        try {
          Iterator iter1=schema.getContents().iterator();
          while (iter1.hasNext()) {
            Object content=iter1.next();
            if (content instanceof XSDImport) {
              XSDImport xsdImport=((XSDImport)content);
              String schemaLocation=xsdImport.getSchemaLocation();
              IPath importLocation=null;
              if (schemaLocation != null) {
                importLocation=new Path(URI.createURI(xsdImport.getSchemaLocation()).path()).makeRelative();
              }
 else {
                continue;
              }
              if (destProjectRelativePaths.contains(importLocation)) {
                xsdImport.setSchemaLocation(ModelUtil.getRelativePath(importLocation,destProjectRelativePath));
              }
            }
          }
          tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
          stream=new FileOutputStream(tempFile);
          stream=new BufferedOutputStream(stream);
          final Element schemaElement=schema.getElement();
          doWriteXmlDocument(xsdDest.getTargetNamespace(),stream,schemaElement);
          stream.close();
          stream=null;
          inputStream=new FileInputStream(tempFile);
          inputStream=new BufferedInputStream(inputStream);
          if (file.exists()) {
            file.setContents(inputStream,true,true,monitor);
          }
 else {
            file.create(inputStream,true,monitor);
          }
          newXsdFiles.add(file);
        }
  finally {
          if (stream != null) {
            try {
              stream.close();
            }
 catch (            IOException err) {
              WebServicePlugin.Util.log(err);
            }
          }
          if (inputStream != null) {
            try {
              inputStream.close();
            }
 catch (            IOException err) {
              WebServicePlugin.Util.log(err);
            }
          }
          if (tempFile != null) {
            try {
              tempFile.delete();
            }
 catch (            RuntimeException err) {
              WebServicePlugin.Util.log(err);
            }
          }
        }
      }
 catch (      Exception e) {
        final Object[] params=new Object[]{xsdDest.getOriginalPath(),destProjectRelativePath,e.getLocalizedMessage()};
        final String msg=WebServicePlugin.Util.getString("String_Node_Str",params);
        final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,e);
        problems.add(status);
      }
    }
  }
  Iterator iter1=newXsdFiles.iterator();
  while (iter1.hasNext()) {
    IFile xsdFile=(IFile)iter1.next();
    try {
      final ModelResource modelResource=(ModelResource)ModelWorkspaceManager.getModelWorkspaceManager().findModelWorkspaceItem(xsdFile,true);
      final List allRoots=modelResource.getAllRootEObjects();
      final Iterator rootIter=allRoots.iterator();
      while (rootIter.hasNext()) {
        final EObject root=(EObject)rootIter.next();
        if (root instanceof XSDSchema) {
          results.add(root);
        }
      }
    }
 catch (    Exception e) {
      final String msg=WebServicePlugin.Util.getString("String_Node_Str",xsdFile);
      final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,e);
      problems.add(status);
    }
  }
  return results;
}

Fixed version (ground truth):
/** 
 * This method is called by   {@link #execute(IProgressMonitor,List)} to process the {@link IWebServiceResource} instances andmake sure that all XSDs are located in the workspace. This includes: <ul> <li>copying into the workspace all XSDs that are outside of the workspace</li> <li>creating XSD files in the workspace for all XSD definitions within the WSDL files</li> </ul> <p> Note that when doing so, it may be required to add to the <code>schemaLocation</code> within the XSDs. </p>
 * @param monitor
 * @param problems
 * @return the set of {@link XSDSchema} instances that should be used by the generator
 * @since 4.2
 */
protected Set doProcessXsds(final IProgressMonitor monitor,final List problems){
  final Set results=new HashSet();
  final Collection xsdDestinations=this.builder.getXsdDestinations();
  final Iterator iter=xsdDestinations.iterator();
  Set newXsdFiles=new HashSet();
  Set destProjectRelativePaths=getDestProjectRelativePaths(xsdDestinations);
  while (iter.hasNext()) {
    final IWebServiceXsdResource xsdDest=(IWebServiceXsdResource)iter.next();
    if (xsdDest == null || xsdDest.getDestinationPath() == null) {
      continue;
    }
    final IPath destFilePath=xsdDest.getDestinationPath();
    final IPath destProjectRelativePath=destFilePath.removeFirstSegments(1);
    final IPath destPath=destProjectRelativePath.removeLastSegments(1);
    final IPath absoluteProjectPath=builder.getParentResource().getProject().getLocation();
    final IPath absoluteDestPath=absoluteProjectPath.append(destPath);
    final File pathFile=new File(absoluteDestPath.toOSString());
    pathFile.mkdirs();
    try {
      builder.getParentResource().refreshLocal(IResource.DEPTH_INFINITE,null);
    }
 catch (    CoreException err1) {
      final Object[] params=new Object[]{builder.getParentResource().getName(),err1.getMessage()};
      final String msg=WebServicePlugin.Util.getString("String_Node_Str",params);
      final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,null);
      problems.add(status);
    }
    final XSDSchema schema=xsdDest.getSchema();
    final IFile file=((IContainer)builder.getParentResource().getProject()).getFile(destProjectRelativePath);
    if (file == null) {
      final Object[] params=new Object[]{xsdDest.getOriginalPath(),destProjectRelativePath};
      final String msg=WebServicePlugin.Util.getString("String_Node_Str",params);
      final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,null);
      problems.add(status);
    }
 else {
      File tempFile=null;
      try {
        OutputStream stream=null;
        InputStream inputStream=null;
        try {
          Iterator iter1=schema.getContents().iterator();
          while (iter1.hasNext()) {
            Object content=iter1.next();
            if (content instanceof XSDImport) {
              XSDImport xsdImport=((XSDImport)content);
              String schemaLocation=xsdImport.getSchemaLocation();
              IPath importLocation=null;
              if (schemaLocation != null) {
                importLocation=new Path(URI.createURI(xsdImport.getSchemaLocation()).path()).makeRelative();
              }
 else {
                continue;
              }
              if (destProjectRelativePaths.contains(importLocation)) {
                xsdImport.setSchemaLocation(ModelUtil.getRelativePath(importLocation,destProjectRelativePath));
              }
            }
          }
          tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
          stream=new FileOutputStream(tempFile);
          stream=new BufferedOutputStream(stream);
          final Element schemaElement=schema.getElement();
          doWriteXmlDocument(xsdDest.getTargetNamespace(),stream,schemaElement);
          stream.close();
          stream=null;
          inputStream=new FileInputStream(tempFile);
          inputStream=new BufferedInputStream(inputStream);
          if (file.exists()) {
            file.setContents(inputStream,true,true,monitor);
          }
 else {
            file.create(inputStream,true,monitor);
          }
          newXsdFiles.add(file);
        }
  finally {
          if (stream != null) {
            try {
              stream.close();
            }
 catch (            IOException err) {
              WebServicePlugin.Util.log(err);
            }
          }
          if (inputStream != null) {
            try {
              inputStream.close();
            }
 catch (            IOException err) {
              WebServicePlugin.Util.log(err);
            }
          }
          if (tempFile != null) {
            try {
              tempFile.delete();
            }
 catch (            RuntimeException err) {
              WebServicePlugin.Util.log(err);
            }
          }
        }
      }
 catch (      Exception e) {
        final Object[] params=new Object[]{xsdDest.getOriginalPath(),destProjectRelativePath,e.getLocalizedMessage()};
        final String msg=WebServicePlugin.Util.getString("String_Node_Str",params);
        final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,e);
        problems.add(status);
      }
    }
  }
  Iterator iter1=newXsdFiles.iterator();
  while (iter1.hasNext()) {
    IFile xsdFile=(IFile)iter1.next();
    try {
      final ModelResource modelResource=(ModelResource)ModelWorkspaceManager.getModelWorkspaceManager().findModelWorkspaceItem(xsdFile,true);
      final List allRoots=modelResource.getAllRootEObjects();
      final Iterator rootIter=allRoots.iterator();
      while (rootIter.hasNext()) {
        final EObject root=(EObject)rootIter.next();
        if (root instanceof XSDSchema) {
          results.add(root);
        }
      }
    }
 catch (    Exception e) {
      final String msg=WebServicePlugin.Util.getString("String_Node_Str",xsdFile);
      final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,0,msg,e);
      problems.add(status);
    }
  }
  return results;
}