nus-yam/ex-repair huggingface dataset:
Program: 10785
Project: 10785
Buggy source:
/** 
 * Starts the job and creates new output streams to the console for each file listed in the console contents.
 * @param contents to stream to the console
 */
public synchronized void startTailing(ConsoleContents contents){
  if (contents != null) {
    List<IConsoleContent> consoleContents=contents.getContents();
    if (consoleContents != null && !consoleContents.isEmpty()) {
      if (activeStreams == null) {
        activeStreams=new LinkedHashMap<ICloudFoundryConsoleOutputStream,Integer>();
      }
      for (      IConsoleContent content : consoleContents) {
        IOConsoleOutputStream stream=console.newOutputStream();
        if (stream != null) {
          ICloudFoundryConsoleOutputStream outStream=content.getOutputStream(stream);
          if (outStream != null) {
            activeStreams.put(outStream,0);
          }
 else {
            try {
              stream.close();
            }
 catch (            IOException ioe) {
            }
          }
        }
      }
      if (!activeStreams.isEmpty()) {
        tailing=true;
        schedule();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Starts stream jobs and creates new output streams to the console for each file listed in the console contents.
 * @param contents to stream to the console
 */
public synchronized void startTailing(ConsoleContents contents){
  clean();
  if (contents != null) {
    List<IConsoleContent> consoleContents=contents.getContents();
    if (consoleContents != null && !consoleContents.isEmpty()) {
      for (      IConsoleContent content : consoleContents) {
        IOConsoleOutputStream stream=console.newOutputStream();
        if (stream != null) {
          ICloudFoundryConsoleOutputStream outStream=content.getOutputStream(stream);
          if (outStream != null) {
            activeStreams.add(new ConsoleStream(getConsoleName(app),outStream));
          }
 else {
            try {
              stream.close();
            }
 catch (            IOException ioe) {
            }
          }
        }
      }
    }
  }
  for (  ConsoleStream stream : activeStreams) {
    stream.tailing(true);
    stream.schedule();
  }
}
Program: 10786
Project: 10786
Buggy source:
public void stopConsole(IServer server,CloudApplication app,int instanceIndex){
  String appUrl=getConsoleId(server,app,instanceIndex);
  CloudFoundryConsole serverLogTail=consoleByUri.get(appUrl);
  if (serverLogTail != null) {
    serverLogTail.stopTailing();
    consoleByUri.remove(appUrl);
  }
}

Fixed version (ground truth):
public void stopConsole(IServer server,CloudApplication app,int instanceIndex){
  String appUrl=getConsoleId(server,app,instanceIndex);
  CloudFoundryConsole serverLogTail=consoleByUri.get(appUrl);
  if (serverLogTail != null) {
    serverLogTail.stop();
    consoleByUri.remove(appUrl);
  }
}
Program: 10787
Project: 10787
Buggy source:
public void stopConsoles(){
  for (  Entry<String,CloudFoundryConsole> tailEntry : consoleByUri.entrySet()) {
    tailEntry.getValue().stopTailing();
  }
}

Fixed version (ground truth):
public void stopConsoles(){
  for (  Entry<String,CloudFoundryConsole> tailEntry : consoleByUri.entrySet()) {
    tailEntry.getValue().stop();
  }
}
Program: 10788
Project: 10788
Buggy source:
/** 
 * Either returns a valid, available Cloud Application URL with the given host, or null
 * @param host
 * @return Non-null valid, available Cloud Application URL.
 * @throws CoreException if URL is not available, is invalid, or list ofdomains cannot be resolved,
 */
public CloudApplicationURL getDefaultApplicationURL(String host){
  List<CloudDomain> domains=getDomains();
  if (domains == null || domains.isEmpty()) {
    return null;
  }
  CloudApplicationURL appURL=null;
  for (  CloudDomain domain : domains) {
    String suggestedURL=host + "String_Node_Str" + domain.getName();
    try {
      appURL=getCloudApplicationURL(suggestedURL);
      break;
    }
 catch (    CoreException ce) {
    }
  }
  return appURL;
}

Fixed version (ground truth):
/** 
 * Either returns a valid, available Cloud Application URL with the given host, or null
 * @param host
 * @return Valid, available Cloud Application URL.
 */
public CloudApplicationURL getDefaultApplicationURL(String host){
  List<CloudDomain> domains=getDomains();
  if (domains == null || domains.isEmpty()) {
    return null;
  }
  CloudApplicationURL appURL=null;
  for (  CloudDomain domain : domains) {
    String suggestedURL=host + "String_Node_Str" + domain.getName();
    try {
      appURL=getCloudApplicationURL(suggestedURL);
      break;
    }
 catch (    CoreException ce) {
    }
  }
  return appURL;
}
Program: 10789
Project: 10789
Buggy source:
/** 
 * The Cloud Foundry application name. This may not necessarily be the same as the associated WTP IModule name or workspace project name, as users are allowed to enter a different name for the application when pushing the application to a Cloud Foundry server.
 * @return Cloud Foundry application name.
 */
public synchronized String getApplicationId(){
  return applicationId;
}

Fixed version (ground truth):
/** 
 * Generally, the application ID is the application module name OR the actual deployed Cloud Application. TODO: NOTE that this appears to be the same as getDeployedName() as well as getName(). Either make it clear that ID and Names are different for a cloud application, or use ONE clearly documented method to obtain the app name.
 */
public synchronized String getApplicationId(){
  return applicationId;
}
Program: 10790
Project: 10790
Buggy source:
public static ApplicationProvider getApplicationProvider(IModule module){
  if (delegates == null) {
    delegates=load();
  }
  ApplicationProvider provider=null;
  for (  Priority priority : Priority.values()) {
    List<ApplicationProvider> providerList=delegates.get(priority);
    if (providerList != null) {
      for (      ApplicationProvider prv : providerList) {
        if (supportsModule(module,prv)) {
          provider=prv;
          break;
        }
      }
    }
  }
  return provider;
}

Fixed version (ground truth):
/** 
 * Get the application delegate provider based on the provider ID (e.g. org.cloudfoundry.ide.eclipse.server.application.javaweb). This is used in case a IModule is not available.
 * @param providerID
 * @return ApplicationProvider matching the specified providerID, or null ifnot found.
 */
public static ApplicationProvider getApplicationProvider(String providerID){
  if (providerID == null) {
    return null;
  }
  if (delegates == null) {
    delegates=load();
  }
  ApplicationProvider provider=null;
  for (  Priority priority : Priority.values()) {
    List<ApplicationProvider> providerList=delegates.get(priority);
    if (providerList != null) {
      for (      ApplicationProvider prv : providerList) {
        if (providerID.equals(prv.getProviderID())) {
          provider=prv;
          break;
        }
      }
    }
  }
  return provider;
}
Program: 10793
Project: 10793
Buggy source:
public void setPassword(String password){
  this.secureStoreDirty=true;
  this.password=password;
  if (getServerWorkingCopy() != null) {
    getServerWorkingCopy().setAttribute(PROP_PASSWORD_ID,(String)null);
  }
  updateServerId();
  getData().setPassword(password);
}

Fixed version (ground truth):
public void setPassword(String password){
  this.secureStoreDirty=true;
  this.password=password;
  if (getServerWorkingCopy() != null) {
    getServerWorkingCopy().setAttribute(PROP_PASSWORD_ID,(String)null);
  }
  updateServerId();
  if (getData() != null) {
    getData().setPassword(password);
  }
}
Program: 10794
Project: 10794
Buggy source:
public void clearApplications(){
  getData().clear();
}

Fixed version (ground truth):
public void clearApplications(){
  ServerData data=getData();
  if (data != null) {
    data.clear();
  }
}
Program: 10795
Project: 10795
Buggy source:
public void tagAsDeployed(IModule module){
synchronized (this) {
    getData().tagAsDeployed(module);
  }
}

Fixed version (ground truth):
public void tagAsDeployed(IModule module){
synchronized (this) {
    if (getData() != null) {
      getData().tagAsDeployed(module);
    }
  }
}
Program: 10796
Project: 10796
Buggy source:
public Collection<CloudFoundryApplicationModule> getApplications(){
  return getData().getApplications();
}

Fixed version (ground truth):
public Collection<CloudFoundryApplicationModule> getApplications(){
  return getData() != null ? getData().getApplications() : new ArrayList<CloudFoundryApplicationModule>(0);
}
Program: 10797
Project: 10797
Buggy source:
private ServerData getData(){
  return CloudFoundryPlugin.getModuleCache().getData(getServerOriginal());
}

Fixed version (ground truth):
/** 
 * Returns the cached server data for the server. In some case the data may be null, if the server has not yet been created but it's available to be configured (e.g while a new server instance is being created).
 * @return cached server data. May be null.
 */
private ServerData getData(){
  return CloudFoundryPlugin.getModuleCache().getData(getServerOriginal());
}
Program: 10798
Project: 10798
Buggy source:
public void setSpace(CloudSpace space){
  secureStoreDirty=true;
  CloudFoundrySpace existingSpace=getCloudFoundrySpace();
  if (space != null) {
    this.cloudSpace=new CloudFoundrySpace(space);
    internalSetOrg(cloudSpace.getOrgName());
    internalSetSpace(cloudSpace.getSpaceName());
  }
 else {
    internalSetOrg(null);
    internalSetSpace(null);
    cloudSpace=null;
  }
  updateServerId();
}

Fixed version (ground truth):
public void setSpace(CloudSpace space){
  secureStoreDirty=true;
  if (space != null) {
    this.cloudSpace=new CloudFoundrySpace(space);
    internalSetOrg(cloudSpace.getOrgName());
    internalSetSpace(cloudSpace.getSpaceName());
  }
 else {
    internalSetOrg(null);
    internalSetSpace(null);
    cloudSpace=null;
  }
  updateServerId();
}
Program: 10799
Project: 10799
Buggy source:
@Override public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
  String serverId=getServerId();
  if (secureStoreDirty || (serverId != null && !serverId.equals(initialServerId))) {
    getData().updateServerId(initialServerId,serverId);
    getData().setPassword(password);
    ServerCredentialsStore store=getCredentialsStore();
    store.setUsername(getUsername());
    store.setPassword(password);
    store.flush(serverId);
    this.initialServerId=serverId;
    this.secureStoreDirty=false;
  }
  super.saveConfiguration(monitor);
}

Fixed version (ground truth):
@Override public void saveConfiguration(IProgressMonitor monitor) throws CoreException {
  String serverId=getServerId();
  if (secureStoreDirty || (serverId != null && !serverId.equals(initialServerId))) {
    if (getData() != null) {
      getData().updateServerId(initialServerId,serverId);
      getData().setPassword(password);
    }
    ServerCredentialsStore store=getCredentialsStore();
    store.setUsername(getUsername());
    store.setPassword(password);
    store.flush(serverId);
    this.initialServerId=serverId;
    this.secureStoreDirty=false;
  }
  super.saveConfiguration(monitor);
}
Program: 10800
Project: 10800
Buggy source:
public void updateApplication(CloudFoundryApplicationModule module){
  getData().updateModule(module);
}

Fixed version (ground truth):
public void updateApplication(CloudFoundryApplicationModule module){
  if (getData() != null) {
    getData().updateModule(module);
  }
}
Program: 10801
Project: 10801
Buggy source:
public String getPassword(){
  if (secureStoreDirty) {
    return password;
  }
  String cachedPassword=getData().getPassword();
  if (cachedPassword != null) {
    return cachedPassword;
  }
  String legacyPassword=getAttribute(PROP_PASSWORD_ID,(String)null);
  if (legacyPassword != null) {
    return legacyPassword;
  }
  return new ServerCredentialsStore(getServerId()).getPassword();
}

Fixed version (ground truth):
public String getPassword(){
  if (secureStoreDirty) {
    return password;
  }
  String cachedPassword=getData() != null ? getData().getPassword() : null;
  if (cachedPassword != null) {
    return cachedPassword;
  }
  String legacyPassword=getAttribute(PROP_PASSWORD_ID,(String)null);
  if (legacyPassword != null) {
    return legacyPassword;
  }
  return new ServerCredentialsStore(getServerId()).getPassword();
}
Program: 10802
Project: 10802
Buggy source:
@Override public void modifyModules(final IModule[] add,IModule[] remove,IProgressMonitor monitor) throws CoreException {
  if (remove != null && remove.length > 0) {
    for (    IModule module : remove) {
      getData().tagAsDeployed(module);
    }
    try {
      getBehaviour().deleteModules(remove,deleteServicesOnModuleRemove.get(),monitor);
    }
 catch (    CoreException e) {
      if (!CloudErrorUtil.isNotFoundException(e)) {
        throw e;
      }
    }
  }
  if (add != null && add.length > 0) {
    for (    IModule module : add) {
      getData().tagAsUndeployed(module);
    }
    if (CloudFoundryPlugin.getCallback().isAutoDeployEnabled()) {
      Job deployModules=new Job("String_Node_Str"){
        @Override protected IStatus run(        IProgressMonitor monitor2){
          Set<IModule> pending=new HashSet<IModule>(Arrays.asList(add));
          try {
            for (            IModule module : add) {
              getBehaviour().deployOrStartModule(new IModule[]{module},true,monitor2);
              pending.remove(module);
            }
          }
 catch (          OperationCanceledException e) {
            doDeleteModules(pending);
            return Status.CANCEL_STATUS;
          }
catch (          CoreException e) {
            CloudFoundryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,CloudFoundryPlugin.PLUGIN_ID,"String_Node_Str",e));
          }
          return Status.OK_STATUS;
        }
      }
;
      deployModules.schedule();
    }
  }
}

Fixed version (ground truth):
@Override public void modifyModules(final IModule[] add,IModule[] remove,IProgressMonitor monitor) throws CoreException {
  if (remove != null && remove.length > 0) {
    if (getData() != null) {
      for (      IModule module : remove) {
        getData().tagAsDeployed(module);
      }
    }
    try {
      getBehaviour().deleteModules(remove,deleteServicesOnModuleRemove.get(),monitor);
    }
 catch (    CoreException e) {
      if (!CloudErrorUtil.isNotFoundException(e)) {
        throw e;
      }
    }
  }
  if (add != null && add.length > 0) {
    if (getData() != null) {
      for (      IModule module : add) {
        getData().tagAsUndeployed(module);
      }
    }
    if (CloudFoundryPlugin.getCallback().isAutoDeployEnabled()) {
      Job deployModules=new Job("String_Node_Str"){
        @Override protected IStatus run(        IProgressMonitor monitor2){
          Set<IModule> pending=new HashSet<IModule>(Arrays.asList(add));
          try {
            for (            IModule module : add) {
              getBehaviour().deployOrStartModule(new IModule[]{module},true,monitor2);
              pending.remove(module);
            }
          }
 catch (          OperationCanceledException e) {
            doDeleteModules(pending);
            return Status.CANCEL_STATUS;
          }
catch (          CoreException e) {
            CloudFoundryPlugin.getDefault().getLog().log(new Status(IStatus.ERROR,CloudFoundryPlugin.PLUGIN_ID,"String_Node_Str",e));
          }
          return Status.OK_STATUS;
        }
      }
;
      deployModules.schedule();
    }
  }
}
Program: 10803
Project: 10803
Buggy source:
public void removeApplication(CloudFoundryApplicationModule cloudModule){
  getData().remove(cloudModule);
}

Fixed version (ground truth):
public void removeApplication(CloudFoundryApplicationModule cloudModule){
  if (getData() != null) {
    getData().remove(cloudModule);
  }
}
Program: 10804
Project: 10804
Buggy source:
public synchronized ServerData getData(IServer server){
  ServerData data=dataByServer.get(server);
  if (data == null) {
    data=new ServerData(server);
    dataByServer.put(server,data);
  }
  return data;
}

Fixed version (ground truth):
public synchronized ServerData getData(IServer server){
  ServerData data=dataByServer.get(server);
  if (data == null && server != null) {
    data=new ServerData(server);
    dataByServer.put(server,data);
  }
  return data;
}
Program: 10805
Project: 10805
Buggy source:
/** 
 * Setting a null status is equivalent to an OK status. Setting an error status without a message may allow listeners to react to the error (e.g. disabling controls like a "Finish" or "OK" button) but not display an error message. To display an error message, a non-null error message is required.
 * @param status
 */
protected void notifyStatusChange(Object data,IStatus status){
  if (status == null) {
    status=Status.OK_STATUS;
  }
  notifyChange(new PartChangeEvent(data,status,this));
}

Fixed version (ground truth):
/** 
 * Notify any listeners that a change has occurred in the UI Part. This notification is accomplished via a status. E.g., an error status indicates that some change in the UI part resulted in an error (e.g. invalid value entered in one of the part's controls). Setting a null status is equivalent to an OK status. The object data may be the result of a change in the UI part (e.g. a set value)
 * @param data event change value, e.g., a set value in a control.
 * @param status reflecting change in UI part
 * @param eventType a type associated with the change in the UI part that alistener may use for additional handling
 */
protected void notifyStatusChange(Object data,IStatus status,int eventType){
  if (status == null) {
    status=Status.OK_STATUS;
  }
  notifyChange(new PartChangeEvent(data,status,this,eventType));
}
Program: 10806
Project: 10806
Buggy source:
protected void notifyChange(PartChangeEvent changeEvent){
  for (  IPartChangeListener listener : listeners) {
    listener.handleChange(changeEvent);
  }
}

Fixed version (ground truth):
/** 
 * Notify any listeners that a chance has occurred in the UI part. The Change event should contain all the information necessary for the listeners to react accordingly.
 * @param changeEvent
 */
protected void notifyChange(PartChangeEvent changeEvent){
  for (  IPartChangeListener listener : listeners) {
    listener.handleChange(changeEvent);
  }
}
Program: 10808
Project: 10808
Buggy source:
public static void logError(IStatus status){
  if (plugin != null) {
    plugin.getLog().log(status);
  }
}

Fixed version (ground truth):
public static void logError(String message,Throwable t){
  log(getErrorStatus(message,t));
}
Program: 10809
Project: 10809
Buggy source:
public static IStatus getErrorStatus(Throwable t){
  return new Status(IStatus.ERROR,PLUGIN_ID,t.getLocalizedMessage(),t);
}

Fixed version (ground truth):
public static IStatus getErrorStatus(Throwable t){
  return new Status(IStatus.ERROR,PLUGIN_ID,t.getMessage(),t);
}
Program: 10810
Project: 10810
Buggy source:
public static boolean hasNature(IResource resource,String natureId){
  if (resource != null && resource.isAccessible()) {
    IProject project=resource.getProject();
    if (project != null) {
      try {
        return project.hasNature(natureId);
      }
 catch (      CoreException e) {
        CloudFoundryPlugin.logError(e);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean hasNature(IResource resource,String natureId){
  if (resource != null && resource.isAccessible()) {
    IProject project=resource.getProject();
    if (project != null) {
      try {
        return project.hasNature(natureId);
      }
 catch (      CoreException e) {
        CloudFoundryPlugin.log(e);
      }
    }
  }
  return false;
}
Program: 10811
Project: 10811
Buggy source:
/** 
 * Obtains the debug mode type of the given module. Note that the module need not be started. It could be stopped, and still have a debug mode associated with it.
 * @param module
 * @param monitor
 * @return
 */
public DebugModeType getDebugModeType(IModule module,IProgressMonitor monitor){
  try {
    CloudFoundryServer cloudServer=getCloudFoundryServer();
    CloudFoundryApplicationModule cloudModule=cloudServer.getApplication(module);
    CloudApplication cloudApplication=cloudModule.getApplication();
    if (cloudApplication != null) {
      return DebugModeType.getDebugModeType(cloudApplication.getDebug());
    }
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.logError(e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Obtains the debug mode type of the given module. Note that the module need not be started. It could be stopped, and still have a debug mode associated with it.
 * @param module
 * @param monitor
 * @return
 */
public DebugModeType getDebugModeType(IModule module,IProgressMonitor monitor){
  try {
    CloudFoundryServer cloudServer=getCloudFoundryServer();
    CloudFoundryApplicationModule cloudModule=cloudServer.getApplication(module);
    CloudApplication cloudApplication=cloudModule.getApplication();
    if (cloudApplication != null) {
      return DebugModeType.getDebugModeType(cloudApplication.getDebug());
    }
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.log(e);
  }
  return null;
}
Program: 10812
Project: 10812
Buggy source:
protected void closeCaldecottTunnels(IProgressMonitor monitor){
  try {
    new TunnelBehaviour(getCloudFoundryServer()).stopAndDeleteAllTunnels(monitor);
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.logError(e);
  }
}

Fixed version (ground truth):
protected void closeCaldecottTunnels(IProgressMonitor monitor){
  try {
    new TunnelBehaviour(getCloudFoundryServer()).stopAndDeleteAllTunnels(monitor);
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.log(e);
  }
}
Program: 10813
Project: 10813
Buggy source:
protected void closeCaldecottTunnelsAsynch(){
  String jobName="String_Node_Str";
  try {
    jobName+="String_Node_Str" + getCloudFoundryServer().getDeploymentName();
  }
 catch (  CoreException e1) {
    CloudFoundryPlugin.logError(e1);
  }
  Job job=new Job(jobName){
    @Override protected IStatus run(    IProgressMonitor monitor){
      closeCaldecottTunnels(monitor);
      return Status.OK_STATUS;
    }
  }
;
  job.setSystem(false);
  job.schedule();
}

Fixed version (ground truth):
protected void closeCaldecottTunnelsAsynch(){
  String jobName="String_Node_Str";
  try {
    jobName+="String_Node_Str" + getCloudFoundryServer().getDeploymentName();
  }
 catch (  CoreException e1) {
    CloudFoundryPlugin.log(e1);
  }
  Job job=new Job(jobName){
    @Override protected IStatus run(    IProgressMonitor monitor){
      closeCaldecottTunnels(monitor);
      return Status.OK_STATUS;
    }
  }
;
  job.setSystem(false);
  job.schedule();
}
Program: 10816
Project: 10816
Buggy source:
public boolean hasFacet(){
  try {
    IFacetedProject facetedProject=ProjectFacetsManager.create(project);
    return facetedProject != null && facetedProject.hasProjectFacet(FACET);
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.logError(e);
    return false;
  }
}

Fixed version (ground truth):
public boolean hasFacet(){
  try {
    IFacetedProject facetedProject=ProjectFacetsManager.create(project);
    return facetedProject != null && facetedProject.hasProjectFacet(FACET);
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.log(e);
    return false;
  }
}
Program: 10817
Project: 10817
Buggy source:
public void removeFacet(){
  if (hasFacet()) {
    try {
      IFacetedProject facetedProject=ProjectFacetsManager.create(project);
      if (facetedProject != null) {
        facetedProject.uninstallProjectFacet(FACET.getDefaultVersion(),null,null);
      }
    }
 catch (    CoreException e) {
      CloudFoundryPlugin.logError(e);
    }
  }
}

Fixed version (ground truth):
public void removeFacet(){
  if (hasFacet()) {
    try {
      IFacetedProject facetedProject=ProjectFacetsManager.create(project);
      if (facetedProject != null) {
        facetedProject.uninstallProjectFacet(FACET.getDefaultVersion(),null,null);
      }
    }
 catch (    CoreException e) {
      CloudFoundryPlugin.log(e);
    }
  }
}
Program: 10818
Project: 10818
Buggy source:
public void addFacet(IProgressMonitor monitor){
  if (canAddFacet()) {
    try {
      IFacetedProject facetedProject=ProjectFacetsManager.create(project);
      if (facetedProject == null) {
        facetedProject=ProjectFacetsManager.create(project,true,monitor);
      }
      if (facetedProject != null) {
        facetedProject.installProjectFacet(FACET.getDefaultVersion(),null,null);
      }
    }
 catch (    CoreException e) {
      CloudFoundryPlugin.logError(e);
    }
  }
}

Fixed version (ground truth):
public void addFacet(IProgressMonitor monitor){
  if (canAddFacet()) {
    try {
      IFacetedProject facetedProject=ProjectFacetsManager.create(project);
      if (facetedProject == null) {
        facetedProject=ProjectFacetsManager.create(project,true,monitor);
      }
      if (facetedProject != null) {
        facetedProject.installProjectFacet(FACET.getDefaultVersion(),null,null);
      }
    }
 catch (    CoreException e) {
      CloudFoundryPlugin.log(e);
    }
  }
}
Program: 10819
Project: 10819
Buggy source:
public boolean hasRuntimeDependencies(){
  try {
    return !getRuntimeDependencyLocations().isEmpty();
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.logError(e);
  }
  return false;
}

Fixed version (ground truth):
public boolean hasRuntimeDependencies(){
  try {
    return !getRuntimeDependencyLocations().isEmpty();
  }
 catch (  CoreException e) {
    CloudFoundryPlugin.log(e);
  }
  return false;
}
Program: 10820
Project: 10820
Buggy source:
protected Collection<String> getNonTestSourceOutputLocations(){
  Collection<String> outputs=getSourceOutputLocations(false);
  Set<String> nonTestOutput=new HashSet<String>(outputs);
  try {
    IPath location=javaProject.getOutputLocation();
    location=getWorkspaceFullPath(location);
    if (location != null) {
      nonTestOutput.add(location.toOSString());
    }
  }
 catch (  JavaModelException e) {
    CloudFoundryPlugin.logError(e);
  }
  return nonTestOutput;
}

Fixed version (ground truth):
protected Collection<String> getNonTestSourceOutputLocations(){
  Collection<String> outputs=getSourceOutputLocations(false);
  Set<String> nonTestOutput=new HashSet<String>(outputs);
  try {
    IPath location=javaProject.getOutputLocation();
    location=getWorkspaceFullPath(location);
    if (location != null) {
      nonTestOutput.add(location.toOSString());
    }
  }
 catch (  JavaModelException e) {
    CloudFoundryPlugin.log(e);
  }
  return nonTestOutput;
}
Program: 10821
Project: 10821
Buggy source:
/** 
 * Returns either test sources, or non-test sources, based on a flag setting. If nothing is found, returns empty list.
 */
protected Collection<IClasspathEntry> getSourceEntries(boolean istest){
  try {
    IClasspathEntry[] rawEntries=javaProject.getRawClasspath();
    if (rawEntries != null) {
      Collection<IClasspathEntry> sourceEntries=new HashSet<IClasspathEntry>();
      for (      IClasspathEntry entry : rawEntries) {
        if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
          IPath path=entry.getPath();
          if (path != null) {
            boolean isTestSource=isTestSource(path.toOSString());
            if ((istest && isTestSource) || (!istest && !isTestSource)) {
              sourceEntries.add(entry);
            }
          }
        }
      }
      return sourceEntries;
    }
  }
 catch (  JavaModelException e) {
    CloudFoundryPlugin.logError(e);
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
/** 
 * Returns either test sources, or non-test sources, based on a flag setting. If nothing is found, returns empty list.
 */
protected Collection<IClasspathEntry> getSourceEntries(boolean istest){
  try {
    IClasspathEntry[] rawEntries=javaProject.getRawClasspath();
    if (rawEntries != null) {
      Collection<IClasspathEntry> sourceEntries=new HashSet<IClasspathEntry>();
      for (      IClasspathEntry entry : rawEntries) {
        if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
          IPath path=entry.getPath();
          if (path != null) {
            boolean isTestSource=isTestSource(path.toOSString());
            if ((istest && isTestSource) || (!istest && !isTestSource)) {
              sourceEntries.add(entry);
            }
          }
        }
      }
      return sourceEntries;
    }
  }
 catch (  JavaModelException e) {
    CloudFoundryPlugin.log(e);
  }
  return Collections.emptyList();
}
Program: 10822
Project: 10822
Buggy source:
public IPackageFragment getDefaultPackageFragment(){
  IJavaProject javaProject=getJavaProject();
  if (getJavaProject() == null) {
    return null;
  }
  IPackageFragmentRoot[] roots=null;
  try {
    IClasspathEntry[] entries=javaProject.getRawClasspath();
    for (    IClasspathEntry entry : entries) {
      if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
        roots=javaProject.findPackageFragmentRoots(entry);
        if (roots != null) {
          break;
        }
      }
    }
  }
 catch (  JavaModelException e) {
    CloudFoundryPlugin.logError(e);
  }
  if (roots != null) {
    IPackageFragment fragment=null;
    for (    IPackageFragmentRoot root : roots) {
      try {
        IJavaElement[] members=root.getChildren();
        if (members != null) {
          for (          IJavaElement element : members) {
            if (element instanceof IPackageFragment) {
              IPackageFragment frag=(IPackageFragment)element;
              if (frag.isDefaultPackage()) {
                fragment=frag;
                break;
              }
            }
          }
        }
        if (fragment != null) {
          break;
        }
      }
 catch (      JavaModelException e) {
        CloudFoundryPlugin.logError(e);
      }
    }
    return fragment;
  }
  return null;
}

Fixed version (ground truth):
public IPackageFragment getDefaultPackageFragment(){
  IJavaProject javaProject=getJavaProject();
  if (getJavaProject() == null) {
    return null;
  }
  IPackageFragmentRoot[] roots=null;
  try {
    IClasspathEntry[] entries=javaProject.getRawClasspath();
    for (    IClasspathEntry entry : entries) {
      if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
        roots=javaProject.findPackageFragmentRoots(entry);
        if (roots != null) {
          break;
        }
      }
    }
  }
 catch (  JavaModelException e) {
    CloudFoundryPlugin.log(e);
  }
  if (roots != null) {
    IPackageFragment fragment=null;
    for (    IPackageFragmentRoot root : roots) {
      try {
        IJavaElement[] members=root.getChildren();
        if (members != null) {
          for (          IJavaElement element : members) {
            if (element instanceof IPackageFragment) {
              IPackageFragment frag=(IPackageFragment)element;
              if (frag.isDefaultPackage()) {
                fragment=frag;
                break;
              }
            }
          }
        }
        if (fragment != null) {
          break;
        }
      }
 catch (      JavaModelException e) {
        CloudFoundryPlugin.log(e);
      }
    }
    return fragment;
  }
  return null;
}
Program: 10824
Project: 10824
Buggy source:
public List<String> findCaldecottTunnelsToClose(CloudFoundryOperations client,String appName,List<String> servicesToUpdate){
  List<String> services=new ArrayList<String>();
  CloudApplication caldecottApp=client.getApplication(appName);
  if (caldecottApp != null) {
    List<String> existingServices=caldecottApp.getServices();
    if (existingServices != null) {
      Set<String> possibleDeletedServices=new HashSet<String>(existingServices);
      for (      String updatedService : servicesToUpdate) {
        if (possibleDeletedServices.contains(updatedService)) {
          possibleDeletedServices.remove(updatedService);
        }
      }
      services.addAll(possibleDeletedServices);
    }
  }
  return services;
}

Fixed version (ground truth):
public List<String> findCaldecottTunnelsToClose(CloudFoundryOperations client,String appName,List<String> servicesToUpdate){
  List<String> services=new ArrayList<String>();
  CloudApplication caldecottApp=client.getApplication(appName);
  if (caldecottApp != null) {
    List<String> existingServices=caldecottApp.getServices();
    if (existingServices != null) {
      Set<String> possibleDeletedServices=new HashSet<String>();
      for (      String existingService : existingServices) {
        if (existingService != null) {
          possibleDeletedServices.add(existingService);
        }
      }
      for (      String updatedService : servicesToUpdate) {
        if (possibleDeletedServices.contains(updatedService)) {
          possibleDeletedServices.remove(updatedService);
        }
      }
      services.addAll(possibleDeletedServices);
    }
  }
  return services;
}
Program: 10825
Project: 10825
Buggy source:
protected boolean bindServiceToCaldecottApp(String serviceName,CloudFoundryOperations client,SubMonitor monitor) throws CoreException {
  CloudApplication caldecottApp=getCaldecottApp(client);
  List<String> updateCaldecottServices=new ArrayList<String>();
  List<String> existingServices=caldecottApp.getServices();
  if (existingServices != null) {
    updateCaldecottServices.addAll(existingServices);
  }
  IModule caldecottModule=getCaldecottModule(monitor.newChild(1));
  if (!updateCaldecottServices.contains(serviceName)) {
    monitor.setTaskName("String_Node_Str" + serviceName + "String_Node_Str");
    updateCaldecottServices.add(serviceName);
    CloudFoundryServerBehaviour behaviour=cloudServer.getBehaviour();
    behaviour.stopModule(new IModule[]{caldecottModule},monitor.newChild(1));
    behaviour.updateServices(TunnelHelper.getTunnelAppName(),updateCaldecottServices,monitor.newChild(1));
    setDeploymentServices(serviceName,monitor.newChild(1));
    return caldecottApp.getServices().contains(serviceName);
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
protected boolean bindServiceToCaldecottApp(String serviceName,CloudFoundryOperations client,SubMonitor monitor) throws CoreException {
  CloudApplication caldecottApp=getCaldecottApp(client);
  List<String> updateCaldecottServices=new ArrayList<String>();
  List<String> existingServices=caldecottApp.getServices();
  if (existingServices != null) {
    for (    String existing : existingServices) {
      if (existing != null) {
        updateCaldecottServices.add(existing);
      }
    }
  }
  IModule caldecottModule=getCaldecottModule(monitor.newChild(1));
  if (!updateCaldecottServices.contains(serviceName)) {
    monitor.setTaskName("String_Node_Str" + serviceName + "String_Node_Str");
    updateCaldecottServices.add(serviceName);
    CloudFoundryServerBehaviour behaviour=cloudServer.getBehaviour();
    behaviour.stopModule(new IModule[]{caldecottModule},monitor.newChild(1));
    behaviour.updateServices(TunnelHelper.getTunnelAppName(),updateCaldecottServices,monitor.newChild(1));
    setDeploymentServices(serviceName,monitor.newChild(1));
    return caldecottApp.getServices().contains(serviceName);
  }
 else {
    return true;
  }
}
Program: 10826
Project: 10826
Buggy source:
protected void unbindServiceToApp(CloudApplication application,CloudService service) throws Exception {
  CloudApplication updatedApplication=getUpdatedApplication(application.getName());
  List<String> boundServices=updatedApplication.getServices();
  List<String> servicesToUpdate=new ArrayList<String>(boundServices);
  if (servicesToUpdate.contains(service.getName())) {
    servicesToUpdate.remove(service.getName());
  }
  serverBehavior.updateServicesAndCloseCaldecottTunnels(application.getName(),servicesToUpdate,new NullProgressMonitor());
}

Fixed version (ground truth):
protected void unbindServiceToApp(CloudApplication application,CloudService service) throws Exception {
  CloudApplication updatedApplication=getUpdatedApplication(application.getName());
  List<String> boundServices=updatedApplication.getServices();
  List<String> servicesToUpdate=new ArrayList<String>();
  for (  String existingService : boundServices) {
    if (existingService != null) {
      servicesToUpdate.add(existingService);
    }
  }
  if (servicesToUpdate.contains(service.getName())) {
    servicesToUpdate.remove(service.getName());
  }
  serverBehavior.updateServicesAndCloseCaldecottTunnels(application.getName(),servicesToUpdate,new NullProgressMonitor());
}
Program: 10827
Project: 10827
Buggy source:
@Override public IStatus performAction(IProgressMonitor monitor) throws CoreException {
  CloudApplication cloudApplication=appModule.getApplication();
  List<String> existingServices=new ArrayList<String>();
  List<String> updatedServices=new ArrayList<String>();
  DeploymentInfo deploymentInfo=appModule.getLastDeploymentInfo();
  if (deploymentInfo == null) {
    deploymentInfo=new DeploymentInfo();
    appModule.setLastDeploymentInfo(deploymentInfo);
    if (cloudApplication != null) {
      existingServices=cloudApplication.getServices();
    }
  }
 else {
    existingServices=deploymentInfo.getServices();
  }
  if (existingServices != null) {
    updatedServices.addAll(existingServices);
  }
  boolean serviceChanges=false;
  List<String> servicesToAdd=getServicesToAdd();
  for (  String serviceToAdd : servicesToAdd) {
    if (!updatedServices.contains(serviceToAdd)) {
      updatedServices.add(serviceToAdd);
      serviceChanges=true;
    }
  }
  serviceChanges|=updatedServices.removeAll(getServicesToRemove());
  if (serviceChanges) {
    if (appModule.getApplication() != null) {
      updateServices(monitor,appModule,serverBehaviour,updatedServices);
    }
    deploymentInfo.setServices(updatedServices);
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
@Override public IStatus performAction(IProgressMonitor monitor) throws CoreException {
  CloudApplication cloudApplication=appModule.getApplication();
  List<String> existingServices=null;
  List<String> updatedServices=new ArrayList<String>();
  DeploymentInfo deploymentInfo=appModule.getLastDeploymentInfo();
  if (deploymentInfo == null) {
    deploymentInfo=new DeploymentInfo();
    appModule.setLastDeploymentInfo(deploymentInfo);
    if (cloudApplication != null) {
      existingServices=cloudApplication.getServices();
    }
  }
 else {
    existingServices=deploymentInfo.getServices();
  }
  if (existingServices != null) {
    for (    String existingService : existingServices) {
      if (existingService != null) {
        updatedServices.add(existingService);
      }
    }
  }
  boolean serviceChanges=false;
  List<String> servicesToAdd=getServicesToAdd();
  for (  String serviceToAdd : servicesToAdd) {
    if (!updatedServices.contains(serviceToAdd)) {
      updatedServices.add(serviceToAdd);
      serviceChanges=true;
    }
  }
  serviceChanges|=updatedServices.removeAll(getServicesToRemove());
  if (serviceChanges) {
    if (appModule.getApplication() != null) {
      updateServices(monitor,appModule,serverBehaviour,updatedServices);
    }
    deploymentInfo.setServices(updatedServices);
  }
  return Status.OK_STATUS;
}
Program: 10830
Project: 10830
Buggy source:
@Override protected void handleCloudSpaceDescriptorSelection(CloudSpacesDescriptor spacesDescriptor){
  initServer();
  spacesFragment=new CloudFoundrySpacesWizardFragment(spaceChangeHandler,cfServer);
}

Fixed version (ground truth):
@Override protected void handleCloudSpaceDescriptorSelection(CloudSpacesDescriptor spacesDescriptor){
  initServer();
  if (spacesDescriptor == null) {
    spacesFragment=null;
  }
 else {
    spacesFragment=new CloudFoundrySpacesWizardFragment(spaceChangeHandler,cfServer);
  }
}
Program: 10831
Project: 10831
Buggy source:
public CloudFoundryClientRequest(CloudFoundryOperations client,CloudFoundryServer server,long requestTimeOut){
  this.timeLeft=requestTimeOut;
  this.client=client;
  this.server=server;
}

Fixed version (ground truth):
public CloudFoundryClientRequest(CloudFoundryOperations client,CloudFoundryServer server,long requestTimeOut){
  this.timeLeft=requestTimeOut;
  this.client=client;
}
Program: 10832
Project: 10832
Buggy source:
public T run(SubMonitor progress) throws CoreException {
  String cloudURL=server.getUrl();
  CloudFoundryLoginHandler handler=new CloudFoundryLoginHandler(client,cloudURL);
  handler.updateProxyInClient(client);
  Exception error=null;
  while (timeLeft > 0) {
    long timeTaken=ONE_SECOND_INTERVAL;
    CloudFoundryException cloudException=null;
    try {
      return doRun(client,progress);
    }
 catch (    NotFinishedStagingException notFinishedError) {
      error=notFinishedError;
      timeTaken=ONE_SECOND_INTERVAL * 2;
    }
catch (    StagingErrorException stagingError) {
      error=stagingError;
      break;
    }
catch (    CoreException e) {
      if (e.getCause() instanceof CloudFoundryException) {
        cloudException=(CloudFoundryException)e.getCause();
      }
 else {
        error=e;
        break;
      }
    }
catch (    CloudFoundryException cfe) {
      cloudException=cfe;
    }
catch (    RestClientException rce) {
      error=rce;
      break;
    }
    if (cloudException != null) {
      error=cloudException;
      if (handler.shouldAttemptClientLogin(cloudException)) {
        handler.login(progress);
        timeTaken=ONE_SECOND_INTERVAL * 2;
      }
 else       if (!CloudErrorUtil.isAppStoppedStateError(cloudException)) {
        break;
      }
    }
    timeLeft-=timeTaken;
    try {
      Thread.sleep(timeTaken);
    }
 catch (    InterruptedException e) {
    }
  }
  if (error == null) {
    error=new CoreException(CloudFoundryPlugin.getErrorStatus("String_Node_Str" + CloudFoundryServerBehaviour.Request.class.getName()));
  }
  if (error instanceof CoreException) {
    throw (CoreException)error;
  }
 else {
    throw CloudErrorUtil.toCoreException(error);
  }
}

Fixed version (ground truth):
public T run(SubMonitor progress) throws CoreException {
  Throwable error=null;
  boolean reattempt=true;
  while (reattempt) {
    long interval=-1;
    try {
      return doRun(client,progress);
    }
 catch (    Throwable e) {
      error=e;
    }
    interval=getWaitInterval(error,progress);
    if (interval > 0) {
      try {
        Thread.sleep(interval);
      }
 catch (      InterruptedException e) {
      }
      timeLeft-=interval;
      reattempt=timeLeft > 0;
    }
 else {
      break;
    }
  }
  if (error == null) {
    error=new CoreException(CloudFoundryPlugin.getErrorStatus("String_Node_Str" + CloudFoundryServerBehaviour.Request.class.getName()));
  }
  if (error instanceof CoreException) {
    throw (CoreException)error;
  }
 else {
    throw CloudErrorUtil.toCoreException(error);
  }
}
Program: 10833
Project: 10833
Buggy source:
public IStatus performAction(IProgressMonitor monitor) throws CoreException {
  tunnelDescriptor=descriptor.getTunnelDescriptor();
  if (tunnelDescriptor == null && descriptor.getCloudService() != null) {
    try {
      TunnelBehaviour handler=new TunnelBehaviour(cloudServer);
      tunnelDescriptor=handler.startCaldecottTunnel(descriptor.getCloudService().getName(),monitor,false);
    }
 catch (    CoreException e) {
      return CloudFoundryPlugin.getErrorStatus(e);
    }
  }
  if (tunnelDescriptor != null) {
    UIJob uiJob=new UIJob(getJobName()){
      @Override public IStatus runInUIThread(      IProgressMonitor monitor){
        IConnectionProfile profile=getConnectionProfile();
        IStatus status=Status.OK_STATUS;
        if (profile != null) {
          Properties properties=profile.getBaseProperties();
          properties.setProperty(IJDBCConnectionProfileConstants.PASSWORD_PROP_ID,tunnelDescriptor.getPassword());
          profile.setBaseProperties(properties);
          status=profile.connect();
        }
 else {
          status=CloudFoundryPlugin.getErrorStatus("String_Node_Str" + tunnelDescriptor.getServiceName());
        }
        return status;
      }
    }
;
    uiJob.schedule();
    return Status.OK_STATUS;
  }
 else {
    return CloudFoundryPlugin.getErrorStatus("String_Node_Str" + tunnelDescriptor.getServiceName());
  }
}

Fixed version (ground truth):
public IStatus performAction(IProgressMonitor monitor) throws CoreException {
  tunnelDescriptor=descriptor.getTunnelDescriptor();
  if (tunnelDescriptor == null && descriptor.getCloudService() != null) {
    try {
      TunnelBehaviour handler=new TunnelBehaviour(cloudServer);
      tunnelDescriptor=handler.startCaldecottTunnel(descriptor.getCloudService().getName(),monitor,false);
    }
 catch (    CoreException e) {
      return CloudFoundryPlugin.getErrorStatus(e);
    }
  }
  if (tunnelDescriptor != null) {
    UIJob uiJob=new UIJob(getJobName()){
      @Override public IStatus runInUIThread(      IProgressMonitor monitor){
        IConnectionProfile profile=getConnectionProfile();
        IStatus status=Status.OK_STATUS;
        if (profile != null) {
          status=profile.connect();
        }
 else {
          status=CloudFoundryPlugin.getErrorStatus("String_Node_Str" + tunnelDescriptor.getServiceName());
        }
        return status;
      }
    }
;
    uiJob.schedule();
    return Status.OK_STATUS;
  }
 else {
    return CloudFoundryPlugin.getErrorStatus("String_Node_Str" + tunnelDescriptor.getServiceName());
  }
}
Program: 10835
Project: 10835
Buggy source:
@Override public IStatus runInUIThread(IProgressMonitor monitor){
  IConnectionProfile profile=getConnectionProfile();
  IStatus status=Status.OK_STATUS;
  if (profile != null) {
    Properties properties=profile.getBaseProperties();
    properties.setProperty(IJDBCConnectionProfileConstants.PASSWORD_PROP_ID,tunnelDescriptor.getPassword());
    profile.setBaseProperties(properties);
    status=profile.connect();
  }
 else {
    status=CloudFoundryPlugin.getErrorStatus("String_Node_Str" + tunnelDescriptor.getServiceName());
  }
  return status;
}

Fixed version (ground truth):
@Override public IStatus runInUIThread(IProgressMonitor monitor){
  IConnectionProfile profile=getConnectionProfile();
  IStatus status=Status.OK_STATUS;
  if (profile != null) {
    status=profile.connect();
  }
 else {
    status=CloudFoundryPlugin.getErrorStatus("String_Node_Str" + tunnelDescriptor.getServiceName());
  }
  return status;
}
Program: 10836
Project: 10836
Buggy source:
@Override protected boolean matchesProfile(IConnectionProfile connection,CaldecottTunnelDescriptor tunnelDescriptor){
  Properties properties=connection.getBaseProperties();
  String userName=properties.getProperty(IJDBCConnectionProfileConstants.USERNAME_PROP_ID);
  String url=properties.getProperty(IJDBCConnectionProfileConstants.URL_PROP_ID);
  String dataBaseName=properties.getProperty(IJDBCConnectionProfileConstants.DATABASE_NAME_PROP_ID);
  return tunnelDescriptor.getUserName().equals(userName) && tunnelDescriptor.getURL().equals(url) && tunnelDescriptor.getDatabaseName().equals(dataBaseName);
}

Fixed version (ground truth):
@Override protected boolean matchesProfile(IConnectionProfile connection,CaldecottTunnelDescriptor tunnelDescriptor){
  Properties properties=connection.getBaseProperties();
  String userName=properties.getProperty(IJDBCConnectionProfileConstants.USERNAME_PROP_ID);
  String password=properties.getProperty(IJDBCConnectionProfileConstants.PASSWORD_PROP_ID);
  String url=properties.getProperty(IJDBCConnectionProfileConstants.URL_PROP_ID);
  String dataBaseName=properties.getProperty(IJDBCConnectionProfileConstants.DATABASE_NAME_PROP_ID);
  return tunnelDescriptor.getUserName().equals(userName) && tunnelDescriptor.getURL().equals(url) && tunnelDescriptor.getDatabaseName().equals(dataBaseName)&& tunnelDescriptor.getPassword().equals(password);
}