Program: 102097
Project: 102097
Buggy source:
/** 
 * @see WebArchiveBuilder#createWebArchive(Properties,IProgressMonitor)
 * @since 7.1
 */
@Override public IStatus createWebArchive(Properties properties,IProgressMonitor monitor){
  try {
    final String contextName=(String)properties.get(WebArchiveBuilderConstants.PROPERTY_CONTEXT_NAME);
    IStatus status=validateContextName(contextName);
    if (IStatus.ERROR == status.getSeverity()) {
      throw new Exception(status.getException());
    }
    final String webServicePluginPath=WebServiceLibPlugin.getDefault().getInstallPath().toOSString();
    final String buildDirectoryName=webServicePluginPath + File.separator + WebArchiveBuilderConstants.BUILD_DIR;
    File buildDirectory=new File(buildDirectoryName);
    buildDirectory.mkdir();
    monitor.subTask(TASK_CREATE_DIRECTORIES);
    final String workDirectoryName=buildDirectoryName + File.separator + WebArchiveBuilderConstants.WORK_DIR;
    File workDirectory=new File(workDirectoryName);
    workDirectory.mkdir();
    FileUtils.removeChildrenRecursively(workDirectory);
    final TempDirectory tempDir=TempDirectory.getTempDirectory(workDirectoryName);
    final String tempDirectoryName=tempDir.getPath();
    final String contextDirectoryName=tempDirectoryName + File.separator + contextName;
    final File contextDirectory=new File(contextDirectoryName);
    contextDirectory.mkdir();
    final String imagesDirectoryName=contextDirectoryName + File.separator + IMAGES;
    final File imagesDirectory=new File(imagesDirectoryName);
    imagesDirectory.mkdir();
    final String webInfDirectoryName=contextDirectoryName + File.separator + WEB_INF;
    final File webInfDirectory=new File(webInfDirectoryName);
    webInfDirectory.mkdir();
    final String webInfWsdlDirectoryName=webInfDirectoryName + File.separator + WSDL;
    final File webInfWsdlDirectory=new File(webInfWsdlDirectoryName);
    final String webInfClassesDirectoryName=webInfDirectoryName + File.separator + CLASSES;
    final String webInfLibDirectoryName=webInfDirectoryName + File.separator + LIB;
    final File webInfClassesDirectory=new File(webInfClassesDirectoryName);
    final File webInfLibDirectory=new File(webInfLibDirectoryName);
    webInfLibDirectory.mkdir();
    webInfClassesDirectory.mkdir();
    monitor.worked(10);
    monitor.subTask(TASK_CREATING_WSDL_FILE);
    boolean containsGlobalDataTypes=generateWsdl(properties,webInfWsdlDirectory);
    monitor.subTask(TASK_COPYING_FILES);
    getWebFiles(contextDirectory,webInfDirectory,containsGlobalDataTypes);
    SecurityCredentials securityCredentials=new SecurityCredentials(properties);
    if (securityCredentials.hasType(WarDeploymentInfoPanel.BASIC)) {
      replaceJBossWebXmlVariables(webInfDirectoryName,securityCredentials.getSecurityRealm());
    }
    replaceWebXmlVariables(webInfDirectoryName,securityCredentials,contextName);
    replaceJBossWSCXFVariables(webInfDirectoryName,properties,securityCredentials);
    createPropertiesFile(webInfClassesDirectory,properties);
    createProviderJavaClasses(webInfLibDirectory,webInfClassesDirectory,properties,securityCredentials);
    monitor.worked(10);
    monitor.subTask(TASK_CREATING_WAR_ARCHIVE);
    final String warFileName=tempDirectoryName + File.separator + contextName+ DOT_WAR;
    AntTasks.zip(contextDirectoryName,warFileName);
    monitor.worked(20);
    final String newWarFileDir=(String)properties.get(WebArchiveBuilderConstants.PROPERTY_WAR_FILE_SAVE_LOCATION);
    File newWarDir=new File(newWarFileDir);
    if (!newWarDir.exists()) {
      newWarDir.mkdir();
    }
    monitor.subTask(TASK_COPYING_WAR_FILE);
    final File warFile=new File(warFileName);
    final String newWarFileName=getFileName((String)properties.get(WebArchiveBuilderConstants.PROPERTY_WAR_FILE_SAVE_LOCATION),contextName + DOT_WAR);
    File newWarFile=new File(newWarFileName);
    if (newWarFile.exists()) {
      if (!newWarFile.delete()) {
        String msg=getString("String_Node_Str");
        throw new Exception(msg);
      }
    }
    if (!warFile.renameTo(newWarFile)) {
      String msg=getString("String_Node_Str");
      throw new Exception(msg);
    }
    monitor.subTask(TASK_CLEANUP);
    tempDir.remove();
    monitor.worked(5);
  }
 catch (  Exception e) {
    final String msg=getString("String_Node_Str");
    final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,WebArchiveBuilderConstants.STATUS_CODE_WAR_FILE_CREATION_FAILED,msg,e);
    WebServicePlugin.Util.log(status);
    return status;
  }
  final String msg=getString("String_Node_Str");
  final IStatus status=new Status(IStatus.OK,WebServicePlugin.PLUGIN_ID,WebArchiveBuilderConstants.STATUS_CODE_WAR_FILE_CREATION_SUCCEEDED,msg,null);
  return status;
}

Fixed version (ground truth):
/** 
 * @see WebArchiveBuilder#createWebArchive(Properties,IProgressMonitor)
 * @since 7.1
 */
@Override public IStatus createWebArchive(Properties properties,IProgressMonitor monitor){
  try {
    final String contextName=(String)properties.get(WebArchiveBuilderConstants.PROPERTY_CONTEXT_NAME);
    IStatus status=validateContextName(contextName);
    if (IStatus.ERROR == status.getSeverity()) {
      throw new Exception(status.getException());
    }
    final String webServicePluginPath=WebServiceLibPlugin.getDefault().getInstallPath().toOSString();
    final String buildDirectoryName=webServicePluginPath + File.separator + WebArchiveBuilderConstants.BUILD_DIR;
    File buildDirectory=new File(buildDirectoryName);
    buildDirectory.mkdir();
    monitor.subTask(TASK_CREATE_DIRECTORIES);
    final String workDirectoryName=buildDirectoryName + File.separator + WebArchiveBuilderConstants.WORK_DIR;
    File workDirectory=new File(workDirectoryName);
    workDirectory.mkdir();
    FileUtils.removeChildrenRecursively(workDirectory);
    final TempDirectory tempDir=TempDirectory.getTempDirectory(workDirectoryName);
    final String tempDirectoryName=tempDir.getPath();
    final String contextDirectoryName=tempDirectoryName + File.separator + contextName;
    final File contextDirectory=new File(contextDirectoryName);
    contextDirectory.mkdir();
    final String imagesDirectoryName=contextDirectoryName + File.separator + IMAGES;
    final File imagesDirectory=new File(imagesDirectoryName);
    imagesDirectory.mkdir();
    final String webInfDirectoryName=contextDirectoryName + File.separator + WEB_INF;
    final File webInfDirectory=new File(webInfDirectoryName);
    webInfDirectory.mkdir();
    final String webInfWsdlDirectoryName=webInfDirectoryName + File.separator + WSDL;
    final File webInfWsdlDirectory=new File(webInfWsdlDirectoryName);
    webInfWsdlDirectory.mkdir();
    final String webInfClassesDirectoryName=webInfDirectoryName + File.separator + CLASSES;
    final String webInfLibDirectoryName=webInfDirectoryName + File.separator + LIB;
    final File webInfClassesDirectory=new File(webInfClassesDirectoryName);
    final File webInfLibDirectory=new File(webInfLibDirectoryName);
    webInfLibDirectory.mkdir();
    webInfClassesDirectory.mkdir();
    monitor.worked(10);
    monitor.subTask(TASK_CREATING_WSDL_FILE);
    boolean containsGlobalDataTypes=generateWsdl(properties,webInfWsdlDirectory);
    monitor.subTask(TASK_COPYING_FILES);
    getWebFiles(contextDirectory,webInfDirectory,containsGlobalDataTypes);
    SecurityCredentials securityCredentials=new SecurityCredentials(properties);
    if (securityCredentials.hasType(WarDeploymentInfoPanel.BASIC)) {
      replaceJBossWebXmlVariables(webInfDirectoryName,securityCredentials.getSecurityRealm());
    }
    replaceWebXmlVariables(webInfDirectoryName,securityCredentials,contextName);
    replaceJBossWSCXFVariables(webInfDirectoryName,properties,securityCredentials);
    createPropertiesFile(webInfClassesDirectory,properties);
    createProviderJavaClasses(webInfLibDirectory,webInfClassesDirectory,properties,securityCredentials);
    monitor.worked(10);
    monitor.subTask(TASK_CREATING_WAR_ARCHIVE);
    final String warFileName=tempDirectoryName + File.separator + contextName+ DOT_WAR;
    AntTasks.zip(contextDirectoryName,warFileName);
    monitor.worked(20);
    final String newWarFileDir=(String)properties.get(WebArchiveBuilderConstants.PROPERTY_WAR_FILE_SAVE_LOCATION);
    File newWarDir=new File(newWarFileDir);
    if (!newWarDir.exists()) {
      newWarDir.mkdir();
    }
    monitor.subTask(TASK_COPYING_WAR_FILE);
    final File warFile=new File(warFileName);
    final String newWarFileName=getFileName((String)properties.get(WebArchiveBuilderConstants.PROPERTY_WAR_FILE_SAVE_LOCATION),contextName + DOT_WAR);
    File newWarFile=new File(newWarFileName);
    if (newWarFile.exists()) {
      if (!newWarFile.delete()) {
        String msg=getString("String_Node_Str");
        throw new Exception(msg);
      }
    }
    if (!warFile.renameTo(newWarFile)) {
      String msg=getString("String_Node_Str");
      throw new Exception(msg);
    }
    monitor.subTask(TASK_CLEANUP);
    tempDir.remove();
    monitor.worked(5);
  }
 catch (  Exception e) {
    final String msg=getString("String_Node_Str");
    final IStatus status=new Status(IStatus.ERROR,WebServicePlugin.PLUGIN_ID,WebArchiveBuilderConstants.STATUS_CODE_WAR_FILE_CREATION_FAILED,msg,e);
    WebServicePlugin.Util.log(status);
    return status;
  }
  final String msg=getString("String_Node_Str");
  final IStatus status=new Status(IStatus.OK,WebServicePlugin.PLUGIN_ID,WebArchiveBuilderConstants.STATUS_CODE_WAR_FILE_CREATION_SUCCEEDED,msg,null);
  return status;
}