Program: 20880
Project: 20880
Buggy source:
@SuppressWarnings("String_Node_Str") public void addServiceDescriptionToDevice(ServiceDescription desc,ConnectableDevice device){
  Class<? extends DeviceService> deviceServiceClass;
  if (isNetcast(desc)) {
    deviceServiceClass=NetcastTVService.class;
    Method m;
    Object result=null;
    try {
      m=deviceServiceClass.getMethod("String_Node_Str");
      result=m.invoke(null);
    }
 catch (    NoSuchMethodException e) {
      e.printStackTrace();
    }
catch (    IllegalArgumentException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
catch (    InvocationTargetException e) {
      e.printStackTrace();
    }
    if (result == null)     return;
    JSONObject discoveryParameters=(JSONObject)result;
    desc.setServiceID(discoveryParameters.optString("String_Node_Str",null));
  }
 else {
    deviceServiceClass=(Class<DeviceService>)deviceClasses.get(desc.getServiceID());
  }
  if (deviceServiceClass.isAssignableFrom(DLNAService.class)) {
    String netcast="String_Node_Str";
    String webos="String_Node_Str";
    int locNet=desc.getLocationXML().indexOf(netcast);
    int locWeb=desc.getLocationXML().indexOf(webos);
    if (locNet == -1 && locWeb == -1)     return;
  }
  ServiceConfig serviceConfig=new ServiceConfig(desc);
  serviceConfig.setListener(DiscoveryManager.this);
  boolean hasType=false;
  boolean hasService=false;
  for (  DeviceService service : device.getServices()) {
    if (service.getServiceDescription().equals(desc.getServiceID())) {
      hasType=true;
      if (service.getServiceDescription().getUUID().equals(desc.getUUID())) {
        hasService=true;
      }
      break;
    }
  }
  if (hasType) {
    if (hasService) {
      device.setServiceDescription(desc);
      DeviceService alreadyAddedService=device.getServiceByName(desc.getServiceID());
      if (alreadyAddedService != null)       alreadyAddedService.setServiceDescription(desc);
    }
    device.removeServiceByName(desc.getServiceID());
  }
  DeviceService deviceService=DeviceService.getService(deviceServiceClass,desc,serviceConfig);
  device.addService(deviceService);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void addServiceDescriptionToDevice(ServiceDescription desc,ConnectableDevice device){
  Class<? extends DeviceService> deviceServiceClass;
  if (isNetcast(desc)) {
    deviceServiceClass=NetcastTVService.class;
    Method m;
    Object result=null;
    try {
      m=deviceServiceClass.getMethod("String_Node_Str");
      result=m.invoke(null);
    }
 catch (    NoSuchMethodException e) {
      e.printStackTrace();
    }
catch (    IllegalArgumentException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
catch (    InvocationTargetException e) {
      e.printStackTrace();
    }
    if (result == null)     return;
    JSONObject discoveryParameters=(JSONObject)result;
    desc.setServiceID(discoveryParameters.optString("String_Node_Str",null));
  }
 else {
    deviceServiceClass=(Class<DeviceService>)deviceClasses.get(desc.getServiceID());
  }
  if (deviceServiceClass.isAssignableFrom(DLNAService.class)) {
    String netcast="String_Node_Str";
    String webos="String_Node_Str";
    int locNet=desc.getLocationXML().indexOf(netcast);
    int locWeb=desc.getLocationXML().indexOf(webos);
    if (locNet == -1 && locWeb == -1)     return;
  }
  ServiceConfig serviceConfig=new ServiceConfig(desc);
  serviceConfig.setListener(DiscoveryManager.this);
  boolean hasType=false;
  boolean hasService=false;
  for (  DeviceService service : device.getServices()) {
    if (service.getServiceDescription().getServiceID().equals(desc.getServiceID())) {
      hasType=true;
      if (service.getServiceDescription().getUUID().equals(desc.getUUID())) {
        hasService=true;
      }
      break;
    }
  }
  if (hasType) {
    if (hasService) {
      device.setServiceDescription(desc);
      DeviceService alreadyAddedService=device.getServiceByName(desc.getServiceID());
      if (alreadyAddedService != null)       alreadyAddedService.setServiceDescription(desc);
      return;
    }
    device.removeServiceByName(desc.getServiceID());
  }
  DeviceService deviceService=DeviceService.getService(deviceServiceClass,desc,serviceConfig);
  device.addService(deviceService);
}