Program: 94354
Project: 94354
Buggy source:
/** 
 * @param reference
 */
private void handleServicePublication(ServiceReference reference){
  Collection svcInterfaces=ServicePropertyUtils.getCollectionProperty(reference,ServicePublication.SERVICE_INTERFACE_NAME);
  if (svcInterfaces == null) {
    logError("String_Node_Str","String_Node_Str" + reference + "String_Node_Str",null);
    return;
  }
  IServiceProperties discoveryServiceProperties=new ServiceProperties();
  discoveryServiceProperties.setPropertyString(ServicePublication.SERVICE_INTERFACE_NAME,ServicePropertyUtils.createStringFromCollection(svcInterfaces));
  Collection configTypes=ServicePropertyUtils.getCollectionProperty(reference,RemoteServicePublication.ENDPOINT_SUPPORTED_CONFIGS);
  if (configTypes != null) {
    discoveryServiceProperties.setPropertyString(RemoteServicePublication.ENDPOINT_SUPPORTED_CONFIGS,ServicePropertyUtils.createStringFromCollection(configTypes));
  }
  Collection serviceIntents=ServicePropertyUtils.getCollectionProperty(reference,RemoteServicePublication.ENDPOINT_SERVICE_INTENTS);
  if (serviceIntents != null) {
    discoveryServiceProperties.setPropertyString(RemoteServicePublication.ENDPOINT_SERVICE_INTENTS,ServicePropertyUtils.createStringFromCollection(serviceIntents));
  }
  Map servicePublicationServiceProperties=ServicePropertyUtils.getMapProperty(reference,ServicePublication.SERVICE_PROPERTIES);
  if (servicePublicationServiceProperties != null)   addPropertiesToDiscoveryServiceProperties(discoveryServiceProperties,servicePublicationServiceProperties);
  ID endpointContainerID=(ID)reference.getProperty(RemoteServicePublication.ENDPOINT_CONTAINERID);
  if (endpointContainerID == null) {
    logError("String_Node_Str","String_Node_Str" + reference + "String_Node_Str",null);
    return;
  }
  discoveryServiceProperties.setPropertyBytes(RemoteServicePublication.ENDPOINT_CONTAINERID,endpointContainerID.toExternalForm().getBytes());
  String endpointNamespace=endpointContainerID.getNamespace().getName();
  discoveryServiceProperties.setPropertyString(RemoteServicePublication.ENDPOINT_CONTAINERID_NAMESPACE,endpointNamespace);
  ID targetContainerID=(ID)reference.getProperty(RemoteServicePublication.TARGET_CONTAINERID);
  if (targetContainerID != null) {
    discoveryServiceProperties.setPropertyBytes(RemoteServicePublication.TARGET_CONTAINERID,targetContainerID.toExternalForm().getBytes());
    String targetNamespace=targetContainerID.getNamespace().getName();
    discoveryServiceProperties.setPropertyString(RemoteServicePublication.TARGET_CONTAINERID_NAMESPACE,targetNamespace);
  }
  String rsnamespace=ServicePropertyUtils.getStringProperty(reference,Constants.SERVICE_NAMESPACE);
  if (rsnamespace != null)   discoveryServiceProperties.setPropertyString(Constants.SERVICE_NAMESPACE,rsnamespace);
  final byte[] remoteServiceIDAsBytes=(byte[])reference.getProperty(Constants.SERVICE_ID);
  if (remoteServiceIDAsBytes == null) {
    logInfo("String_Node_Str","String_Node_Str" + reference + "String_Node_Str"+ Constants.SERVICE_ID+ "String_Node_Str",null);
    return;
  }
  discoveryServiceProperties.setPropertyBytes(Constants.SERVICE_ID,remoteServiceIDAsBytes);
  IDiscoveryAdvertiser advertiser2=getAdvertiser();
  if (advertiser2 == null) {
    logInfo("String_Node_Str","String_Node_Str" + reference + "String_Node_Str",null);
    return;
  }
  Namespace advertiserNamespace=advertiser2.getServicesNamespace();
  IServiceInfo svcInfo=null;
  try {
    IServiceTypeID serviceTypeID=createServiceTypeID(servicePublicationServiceProperties,advertiserNamespace);
    URI uri=createURI(endpointContainerID);
    String serviceName=getPropertyWithDefault(servicePublicationServiceProperties,RemoteServicePublication.SERVICE_NAME,(RemoteServicePublication.DEFAULT_SERVICE_NAME_PREFIX + new String(remoteServiceIDAsBytes)));
    svcInfo=new ServiceInfo(uri,serviceName,serviceTypeID,discoveryServiceProperties);
  }
 catch (  IDCreateException e) {
    logError("String_Node_Str","String_Node_Str",e);
    return;
  }
catch (  URISyntaxException e) {
    logError("String_Node_Str","String_Node_Str",e);
    return;
  }
  fireHostPublishUnpublish(reference,svcInfo,true);
synchronized (serviceInfos) {
    try {
      trace("String_Node_Str","String_Node_Str" + reference + "String_Node_Str"+ svcInfo);
      advertiser2.registerService(svcInfo);
      addServiceInfo(reference,svcInfo);
    }
 catch (    ECFRuntimeException e) {
      logError("String_Node_Str","String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param reference
 */
private void handleServicePublication(ServiceReference reference){
  Collection svcInterfaces=ServicePropertyUtils.getCollectionProperty(reference,ServicePublication.SERVICE_INTERFACE_NAME);
  if (svcInterfaces == null) {
    logError("String_Node_Str","String_Node_Str" + reference + "String_Node_Str",null);
    return;
  }
  IServiceProperties discoveryServiceProperties=new ServiceProperties();
  discoveryServiceProperties.setPropertyString(ServicePublication.SERVICE_INTERFACE_NAME,ServicePropertyUtils.createStringFromCollection(svcInterfaces));
  Collection configTypes=ServicePropertyUtils.getCollectionProperty(reference,RemoteServicePublication.ENDPOINT_SUPPORTED_CONFIGS);
  if (configTypes != null) {
    discoveryServiceProperties.setPropertyString(RemoteServicePublication.ENDPOINT_SUPPORTED_CONFIGS,ServicePropertyUtils.createStringFromCollection(configTypes));
  }
  Collection serviceIntents=ServicePropertyUtils.getCollectionProperty(reference,RemoteServicePublication.ENDPOINT_SERVICE_INTENTS);
  if (serviceIntents != null) {
    discoveryServiceProperties.setPropertyString(RemoteServicePublication.ENDPOINT_SERVICE_INTENTS,ServicePropertyUtils.createStringFromCollection(serviceIntents));
  }
  Map servicePublicationServiceProperties=ServicePropertyUtils.getMapProperty(reference,ServicePublication.SERVICE_PROPERTIES);
  if (servicePublicationServiceProperties != null)   addPropertiesToDiscoveryServiceProperties(discoveryServiceProperties,servicePublicationServiceProperties);
  ID endpointContainerID=(ID)reference.getProperty(RemoteServicePublication.ENDPOINT_CONTAINERID);
  if (endpointContainerID == null) {
    logError("String_Node_Str","String_Node_Str" + reference + "String_Node_Str",null);
    return;
  }
  discoveryServiceProperties.setPropertyBytes(RemoteServicePublication.ENDPOINT_CONTAINERID,endpointContainerID.toExternalForm().getBytes());
  String endpointNamespace=endpointContainerID.getNamespace().getName();
  discoveryServiceProperties.setPropertyString(RemoteServicePublication.ENDPOINT_CONTAINERID_NAMESPACE,endpointNamespace);
  ID targetContainerID=(ID)reference.getProperty(RemoteServicePublication.TARGET_CONTAINERID);
  if (targetContainerID != null) {
    discoveryServiceProperties.setPropertyBytes(RemoteServicePublication.TARGET_CONTAINERID,targetContainerID.toExternalForm().getBytes());
    String targetNamespace=targetContainerID.getNamespace().getName();
    discoveryServiceProperties.setPropertyString(RemoteServicePublication.TARGET_CONTAINERID_NAMESPACE,targetNamespace);
  }
  String rsnamespace=ServicePropertyUtils.getStringProperty(reference,Constants.SERVICE_NAMESPACE);
  if (rsnamespace != null)   discoveryServiceProperties.setPropertyString(Constants.SERVICE_NAMESPACE,rsnamespace);
  final byte[] remoteServiceIDAsBytes=(byte[])reference.getProperty(Constants.SERVICE_ID);
  if (remoteServiceIDAsBytes == null) {
    logInfo("String_Node_Str","String_Node_Str" + reference + "String_Node_Str"+ Constants.SERVICE_ID+ "String_Node_Str",null);
    return;
  }
  discoveryServiceProperties.setPropertyBytes(Constants.SERVICE_ID,remoteServiceIDAsBytes);
  IDiscoveryAdvertiser advertiser2=getAdvertiser();
  if (advertiser2 == null) {
    logInfo("String_Node_Str","String_Node_Str" + reference + "String_Node_Str",null);
    return;
  }
  Namespace advertiserNamespace=advertiser2.getServicesNamespace();
  IServiceInfo svcInfo=null;
  try {
    IServiceTypeID serviceTypeID=createServiceTypeID(servicePublicationServiceProperties,advertiserNamespace);
    String serviceName=getPropertyWithDefault(servicePublicationServiceProperties,RemoteServicePublication.SERVICE_NAME,(RemoteServicePublication.DEFAULT_SERVICE_NAME_PREFIX + new String(remoteServiceIDAsBytes)));
    URI uri=createURI(endpointContainerID,"String_Node_Str" + serviceName);
    svcInfo=new ServiceInfo(uri,serviceName,serviceTypeID,discoveryServiceProperties);
  }
 catch (  IDCreateException e) {
    logError("String_Node_Str","String_Node_Str",e);
    return;
  }
catch (  URISyntaxException e) {
    logError("String_Node_Str","String_Node_Str",e);
    return;
  }
  fireHostPublishUnpublish(reference,svcInfo,true);
synchronized (serviceInfos) {
    try {
      trace("String_Node_Str","String_Node_Str" + reference + "String_Node_Str"+ svcInfo);
      advertiser2.registerService(svcInfo);
      addServiceInfo(reference,svcInfo);
    }
 catch (    ECFRuntimeException e) {
      logError("String_Node_Str","String_Node_Str",e);
    }
  }
}