Program: 10960
Project: 10960
Buggy source:
public synchronized CaldecottTunnelDescriptor startCaldecottTunnel(final String serviceName,final IProgressMonitor monitor) throws CoreException {
  final List<CaldecottTunnelDescriptor> tunnel=new ArrayList<CaldecottTunnelDescriptor>(1);
  cloudServer.getBehaviour().new Request<CaldecottTunnelDescriptor>(){
    @Override protected CaldecottTunnelDescriptor doRun(    CloudFoundryClient client,    SubMonitor progress) throws CoreException {
      CloudApplication caldecottApp=getCaldecottApp(progress);
      if (caldecottApp == null) {
        return null;
      }
      progress.setTaskName("String_Node_Str" + serviceName + "String_Node_Str");
      bindServiceToCaldecottApp(caldecottApp,serviceName,progress);
      int unusedPort=CloudFoundryPlugin.getCaldecottTunnelCache().getUnusedPort();
      CaldecottTunnelDescriptor oldDescriptor=CloudFoundryPlugin.getCaldecottTunnelCache().getDescriptor(cloudServer,serviceName);
      if (oldDescriptor != null) {
        try {
          stopCaldecottTunnel(serviceName);
        }
 catch (        CoreException e) {
          CloudFoundryPlugin.logError(NLS.bind("String_Node_Str",new Object[]{serviceName,oldDescriptor.tunnelPort(),unusedPort}));
        }
      }
      InetSocketAddress local=new InetSocketAddress(LOCAL_HOST,unusedPort);
      progress.setTaskName("String_Node_Str" + serviceName);
      String url=TunnelHelper.getTunnelUri(client);
      Map<String,String> info=getTunnelInfo(client,serviceName,progress);
      if (info == null) {
        return null;
      }
      String host=info.get("String_Node_Str");
      int port=Integer.valueOf(info.get("String_Node_Str"));
      String auth=TunnelHelper.getTunnelAuth(client);
      String serviceUserName=info.get("String_Node_Str");
      String servicePassword=info.get("String_Node_Str");
      String dataBase=getServiceVendor(serviceName,progress);
      String name=info.get("String_Node_Str");
      if (name == null) {
        name=info.get("String_Node_Str") != null ? info.get("String_Node_Str") : info.get("String_Node_Str");
      }
      TunnelServer tunnelServer=new TunnelServer(local,new HttpTunnelFactory(url,host,port,auth),getTunnelServerThreadExecutor());
      progress.setTaskName("String_Node_Str" + serviceName);
      tunnelServer.start();
      if (oldDescriptor != null) {
        CloudFoundryPlugin.getCaldecottTunnelCache().removeDescriptor(cloudServer,serviceName);
      }
      CaldecottTunnelDescriptor descriptor=new CaldecottTunnelDescriptor(serviceUserName,servicePassword,name,serviceName,dataBase,tunnelServer,unusedPort);
      CloudFoundryPlugin.getCaldecottTunnelCache().addDescriptor(cloudServer,descriptor);
      tunnel.add(descriptor);
      CloudFoundryCallback callBack=CloudFoundryPlugin.getCallback();
      List<CaldecottTunnelDescriptor> descriptors=new ArrayList<CaldecottTunnelDescriptor>();
      descriptors.add(descriptor);
      callBack.displayCaldecottTunnelConnections(cloudServer,descriptors);
      return descriptor;
    }
  }
.run(monitor);
  return tunnel.size() > 0 ? tunnel.get(0) : null;
}

Fixed version (ground truth):
public synchronized CaldecottTunnelDescriptor startCaldecottTunnel(final String serviceName,final IProgressMonitor monitor) throws CoreException {
  final List<CaldecottTunnelDescriptor> tunnel=new ArrayList<CaldecottTunnelDescriptor>(1);
  cloudServer.getBehaviour().new Request<CaldecottTunnelDescriptor>(){
    @Override protected CaldecottTunnelDescriptor doRun(    final CloudFoundryClient client,    SubMonitor progress) throws CoreException {
      final CloudApplication caldecottApp=getCaldecottApp(progress);
      if (caldecottApp == null) {
        return null;
      }
      progress.setTaskName("String_Node_Str" + serviceName + "String_Node_Str");
      bindServiceToCaldecottApp(caldecottApp,serviceName,progress);
      int ticks=1;
      long sleep=5000;
      progress.setTaskName("String_Node_Str");
      new WaitWithProgressJob<Boolean>(ticks,sleep){
        @Override protected Boolean runInWait(        IProgressMonitor monitor){
          if (!caldecottApp.getState().equals(CloudApplication.AppState.STARTED)) {
            client.startApplication(caldecottApp.getName());
            return null;
          }
          return true;
        }
      }
.run(monitor);
      int unusedPort=CloudFoundryPlugin.getCaldecottTunnelCache().getUnusedPort();
      CaldecottTunnelDescriptor oldDescriptor=CloudFoundryPlugin.getCaldecottTunnelCache().getDescriptor(cloudServer,serviceName);
      if (oldDescriptor != null) {
        try {
          stopCaldecottTunnel(serviceName);
        }
 catch (        CoreException e) {
          CloudFoundryPlugin.logError(NLS.bind("String_Node_Str",new Object[]{serviceName,oldDescriptor.tunnelPort(),unusedPort}));
        }
      }
      InetSocketAddress local=new InetSocketAddress(LOCAL_HOST,unusedPort);
      String url=TunnelHelper.getTunnelUri(client);
      Map<String,String> info=getTunnelInfo(client,serviceName,progress);
      if (info == null) {
        CloudFoundryPlugin.logError(NLS.bind("String_Node_Str",new Object[]{serviceName,unusedPort}));
        return null;
      }
      String host=info.get("String_Node_Str");
      int port=Integer.valueOf(info.get("String_Node_Str"));
      String auth=TunnelHelper.getTunnelAuth(client);
      String serviceUserName=info.get("String_Node_Str");
      String servicePassword=info.get("String_Node_Str");
      String dataBase=getServiceVendor(serviceName,progress);
      String name=info.get("String_Node_Str");
      if (name == null) {
        name=info.get("String_Node_Str") != null ? info.get("String_Node_Str") : info.get("String_Node_Str");
      }
      TunnelServer tunnelServer=new TunnelServer(local,new HttpTunnelFactory(url,host,port,auth),getTunnelServerThreadExecutor());
      progress.setTaskName("String_Node_Str" + serviceName);
      tunnelServer.start();
      if (oldDescriptor != null) {
        CloudFoundryPlugin.getCaldecottTunnelCache().removeDescriptor(cloudServer,serviceName);
      }
      CaldecottTunnelDescriptor descriptor=new CaldecottTunnelDescriptor(serviceUserName,servicePassword,name,serviceName,dataBase,tunnelServer,unusedPort);
      CloudFoundryPlugin.getCaldecottTunnelCache().addDescriptor(cloudServer,descriptor);
      tunnel.add(descriptor);
      CloudFoundryCallback callBack=CloudFoundryPlugin.getCallback();
      List<CaldecottTunnelDescriptor> descriptors=new ArrayList<CaldecottTunnelDescriptor>();
      descriptors.add(descriptor);
      callBack.displayCaldecottTunnelConnections(cloudServer,descriptors);
      return descriptor;
    }
  }
.run(monitor);
  return tunnel.size() > 0 ? tunnel.get(0) : null;
}