Program: 20960
Project: 20960
Buggy source:
public void connectToWebApp(final WebOSWebAppSession webAppSession,final WebAppSession.MessageListener messageListener,final ResponseListener<Object> connectionListener){
  if (webAppSession == null || webAppSession.launchSession == null || webAppSession.launchSession.getRawData() == null)   Util.postError(connectionListener,new ServiceCommandError(0,"String_Node_Str",null));
  final LaunchSession launchSession=webAppSession.launchSession;
  String uri="String_Node_Str";
  JSONObject payload=new JSONObject();
  if (launchSession.getAppId() != null) {
    try {
      payload.put("String_Node_Str",launchSession.getAppId());
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  if (mAppToAppMessageListeners.get(launchSession.getAppId()) == null)   mAppToAppMessageListeners.put(launchSession.getAppId(),new URLServiceSubscription<WebAppSession.MessageListener>(this,null,null,null));
  ResponseListener<Object> responseListener=new ResponseListener<Object>(){
    @Override public void onSuccess(    Object response){
      JSONObject jsonObj=(JSONObject)response;
      Log.d(Util.T,"String_Node_Str" + jsonObj.toString());
      String state="String_Node_Str";
      try {
        state=jsonObj.getString("String_Node_Str");
      }
 catch (      JSONException e) {
        return;
      }
      if (!state.equalsIgnoreCase("String_Node_Str"))       return;
      if (messageListener != null) {
        URLServiceSubscription<MessageListener> messageSubscription=mAppToAppMessageListeners.get(launchSession.getAppId());
        messageSubscription.addListener(messageListener);
      }
      if (connectionListener != null)       connectionListener.onSuccess(null);
    }
    @Override public void onError(    ServiceCommandError error){
      ServiceSubscription<WebAppSession.MessageListener> subscription=mAppToAppMessageListeners.get(launchSession.getAppId());
      if (subscription != null) {
        if (serviceDescription.getVersion().contains("String_Node_Str")) {
          subscription.unsubscribe();
          mAppToAppMessageListeners.remove(subscription);
        }
      }
      Util.postError(connectionListener,error);
    }
  }
;
  URLServiceSubscription<ResponseListener<Object>> subscription=new URLServiceSubscription<ResponseListener<Object>>(this,uri,payload,responseListener);
  subscription.send();
  mAppToAppConnectionListeners.put(launchSession.getAppId(),subscription);
}

Fixed version (ground truth):
public void connectToWebApp(final WebOSWebAppSession webAppSession,final WebAppSession.MessageListener messageListener,final ResponseListener<Object> connectionListener){
  if (webAppSession == null || webAppSession.launchSession == null || webAppSession.launchSession.getRawData() == null)   Util.postError(connectionListener,new ServiceCommandError(0,"String_Node_Str",null));
  final LaunchSession launchSession=webAppSession.launchSession;
  String uri="String_Node_Str";
  JSONObject payload=new JSONObject();
  if (launchSession.getAppId() != null) {
    try {
      payload.put("String_Node_Str",launchSession.getAppId());
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  if (mAppToAppMessageListeners.get(launchSession.getAppId()) == null)   mAppToAppMessageListeners.put(launchSession.getAppId(),new URLServiceSubscription<WebAppSession.MessageListener>(this,null,null,true,null));
  ResponseListener<Object> responseListener=new ResponseListener<Object>(){
    @Override public void onSuccess(    Object response){
      JSONObject jsonObj=(JSONObject)response;
      Log.d(Util.T,"String_Node_Str" + jsonObj.toString());
      String state="String_Node_Str";
      try {
        state=jsonObj.getString("String_Node_Str");
      }
 catch (      JSONException e) {
        return;
      }
      if (!state.equalsIgnoreCase("String_Node_Str"))       return;
      if (messageListener != null) {
        URLServiceSubscription<MessageListener> messageSubscription=mAppToAppMessageListeners.get(launchSession.getAppId());
        messageSubscription.addListener(messageListener);
      }
      if (connectionListener != null)       connectionListener.onSuccess(null);
    }
    @Override public void onError(    ServiceCommandError error){
      ServiceSubscription<WebAppSession.MessageListener> subscription=mAppToAppMessageListeners.get(launchSession.getAppId());
      if (subscription != null) {
        if (serviceDescription.getVersion().contains("String_Node_Str")) {
          subscription.unsubscribe();
          mAppToAppMessageListeners.remove(subscription);
        }
      }
      Util.postError(connectionListener,error);
    }
  }
;
  URLServiceSubscription<ResponseListener<Object>> subscription=new URLServiceSubscription<ResponseListener<Object>>(this,uri,payload,true,responseListener);
  subscription.send();
  mAppToAppConnectionListeners.put(launchSession.getAppId(),subscription);
}