Program: 20799
Project: 20799
Buggy source:
private void connect(final Boolean joinOnly,final ResponseListener<Object> connectionListener){
  if (socket != null && socket.getState() == WebOSTVServiceSocketClient.State.CONNECTING) {
    if (connectionListener != null)     ;
    connectionListener.onError(new ServiceCommandError(0,"String_Node_Str",null));
    return;
  }
  if (isConnected()) {
    if (connectionListener != null)     connectionListener.onSuccess(null);
    return;
  }
  mConnectionListener=new ResponseListener<ServiceCommand<ResponseListener<Object>>>(){
    @Override public void onError(    ServiceCommandError error){
      if (socket != null)       disconnectFromWebApp();
      if (connectionListener != null) {
        if (error == null)         error=new ServiceCommandError(0,"String_Node_Str",null);
        connectionListener.onError(error);
      }
    }
    @Override public void onSuccess(    ServiceCommand<ResponseListener<Object>> object){
      ResponseListener<Object> finalConnectionListener=new ResponseListener<Object>(){
        @Override public void onError(        ServiceCommandError error){
          disconnectFromWebApp();
          if (mConnectionListener != null)           mConnectionListener.onError(error);
        }
        @Override public void onSuccess(        Object object){
          connected=true;
          if (connectionListener != null)           connectionListener.onSuccess(object);
        }
      }
;
      service.connectToWebApp(WebOSWebAppSession.this,joinOnly,finalConnectionListener);
    }
  }
;
  if (socket != null) {
    if (socket.isConnected())     mConnectionListener.onSuccess(null);
 else     socket.connect();
  }
 else {
    socket=new WebOSTVServiceSocketClient(service,WebOSTVServiceSocketClient.getURI(service));
    socket.setListener(mSocketListener);
    socket.connect();
  }
}

Fixed version (ground truth):
private void connect(final Boolean joinOnly,final ResponseListener<Object> connectionListener){
  if (socket != null && socket.getState() == WebOSTVServiceSocketClient.State.CONNECTING) {
    if (connectionListener != null)     ;
    connectionListener.onError(new ServiceCommandError(0,"String_Node_Str",null));
    return;
  }
  if (isConnected()) {
    if (connectionListener != null)     connectionListener.onSuccess(null);
    return;
  }
  mConnectionListener=new ResponseListener<ServiceCommand<ResponseListener<Object>>>(){
    @Override public void onError(    ServiceCommandError error){
      if (socket != null)       disconnectFromWebApp();
      if (connectionListener != null) {
        if (error == null)         error=new ServiceCommandError(0,"String_Node_Str",null);
        connectionListener.onError(error);
      }
    }
    @Override public void onSuccess(    ServiceCommand<ResponseListener<Object>> object){
      ResponseListener<Object> finalConnectionListener=new ResponseListener<Object>(){
        @Override public void onError(        ServiceCommandError error){
          disconnectFromWebApp();
          if (connectionListener != null)           connectionListener.onError(error);
        }
        @Override public void onSuccess(        Object object){
          connected=true;
          if (connectionListener != null)           connectionListener.onSuccess(object);
        }
      }
;
      service.connectToWebApp(WebOSWebAppSession.this,joinOnly,finalConnectionListener);
    }
  }
;
  if (socket != null) {
    if (socket.isConnected())     mConnectionListener.onSuccess(null);
 else     socket.connect();
  }
 else {
    socket=new WebOSTVServiceSocketClient(service,WebOSTVServiceSocketClient.getURI(service));
    socket.setListener(mSocketListener);
    socket.connect();
  }
}