Program: 134874
Project: 134874
Buggy source:
/** 
 * Tries to create a notification channel (using quality of service and administrative properties  specified by configQofS() and configAdminProps() respectively). If this succeeds, then registers this channel with the naming service. <p> Should only be invoked when the channel that this supplier or consumer is attempting to connect to does not exist. However even with prior check for the existence of this channel, a race condition with other suppliers or consumers can lead to multiple attempts to create the same channel, which will result in <code>NameAlreadyUsed</code> exception. <p> Design note: Currently the TAO notification extensions are used to synch channel creation with other clients by supplying the channel name to the factory. If we want to use only standard NC factories then we'd have to implement our own locking mechanisms in all  ACS consumer and supplier classes, see http://jira.alma.cl/browse/COMP-2808
 * @return Reference to the newly created channel.
 * @param channelName Name of the channel to create.
 * @param channelKind Kind of the channel as registered with the CORBA naming service.
 * @param notifyFactoryName Name of the notification service as registered with the CORBA naming service.
 * @throws AcsJException Standard ACS Java exception.
 * @throws NameMapError (@TODO check in TAO code what this means!) 
 * @throws NameAlreadyUsed thrown if the channel of this name already exists.
 */
public EventChannel createNotificationChannel(String channelName,String channelKind,String notifyFactoryName) throws AcsJException, NameAlreadyUsed, NameMapError {
  LOG_NC_ChannelCreated_ATTEMPT.log(m_logger,channelName,notifyFactoryName);
  EventChannel retValue=null;
  int channelId=-1;
  final String standardEventFactoryId=org.omg.CosNotifyChannelAdmin.EventChannelFactoryHelper.id();
  final String specialEventFactoryId=gov.sandia.NotifyMonitoringExt.EventChannelFactoryHelper.id();
  try {
    NameComponent[] t_NameFactory={new NameComponent(notifyFactoryName,"String_Node_Str")};
    org.omg.CORBA.Object notifyFactoryObj=null;
    EventChannelFactory notifyFactory=null;
    try {
      notifyFactoryObj=getNamingService().resolve(t_NameFactory);
    }
 catch (    org.omg.CosNaming.NamingContextPackage.NotFound ex) {
      String reason="String_Node_Str" + notifyFactoryName + "String_Node_Str"+ ex.why.toString();
      AcsJCORBAProblemEx ex2=new AcsJCORBAProblemEx();
      ex2.setInfo(reason);
      throw ex2;
    }
    try {
      notifyFactory=EventChannelFactoryHelper.narrow(notifyFactoryObj);
    }
 catch (    BAD_PARAM ex) {
      String errMsg="String_Node_Str" + notifyFactoryName + "String_Node_Str"+ specialEventFactoryId;
      if (notifyFactoryObj._is_a(standardEventFactoryId)) {
        errMsg+="String_Node_Str" + standardEventFactoryId + "String_Node_Str";
      }
 else {
        errMsg+="String_Node_Str" + standardEventFactoryId;
      }
      m_logger.warning(errMsg);
      AcsJNarrowFailedEx ex2=new AcsJNarrowFailedEx(ex);
      ex2.setNarrowType(specialEventFactoryId);
      throw ex2;
    }
    IntHolder channelIdHolder=new IntHolder();
    retValue=createNotifyChannel_internal(notifyFactory,m_channelProperties.configQofS(channelName),m_channelProperties.configAdminProps(channelName),channelName,channelIdHolder);
    if (retValue == null) {
      Throwable cause=new Throwable("String_Node_Str" + channelName + "String_Node_Str");
      throw new alma.ACSErrTypeJavaNative.wrappers.AcsJJavaLangEx(cause);
    }
    channelId=channelIdHolder.value;
    try {
      NameComponent[] t_NameChannel={new NameComponent(channelName,channelKind)};
      getNamingService().rebind(t_NameChannel,retValue);
    }
 catch (    org.omg.CosNaming.NamingContextPackage.NotFound ex) {
      String reason="String_Node_Str" + channelName + "String_Node_Str"+ ex.why.toString();
      AcsJCORBAProblemEx ex2=new AcsJCORBAProblemEx(ex);
      ex2.setInfo(reason);
      throw ex2;
    }
  }
 catch (  org.omg.CosNaming.NamingContextPackage.CannotProceed e) {
    Throwable cause=new Throwable(e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
catch (  org.omg.CosNaming.NamingContextPackage.InvalidName e) {
    Throwable cause=new Throwable(e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
catch (  org.omg.CosNotification.UnsupportedAdmin e) {
    Throwable cause=new Throwable("String_Node_Str" + channelName + "String_Node_Str"+ e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
catch (  org.omg.CosNotification.UnsupportedQoS e) {
    Throwable cause=new Throwable("String_Node_Str" + channelName + "String_Node_Str"+ e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
  LOG_NC_ChannelCreated_OK.log(m_logger,channelName,channelId,notifyFactoryName);
  return retValue;
}

Fixed version (ground truth):
/** 
 * Tries to create a notification channel (using quality of service and administrative properties  specified by configQofS() and configAdminProps() respectively). If this succeeds, then registers this channel with the naming service. <p> Should only be invoked when the channel that this supplier or consumer is attempting to connect to does not exist. However even with prior check for the existence of this channel, a race condition with other suppliers or consumers can lead to multiple attempts to create the same channel, which will result in <code>NameAlreadyUsed</code> exception. <p> Design note: Currently the TAO notification extensions are used to synch channel creation with other clients by supplying the channel name to the factory. If we want to use only standard NC factories then we'd have to implement our own locking mechanisms in all  ACS consumer and supplier classes, see http://jira.alma.cl/browse/COMP-2808
 * @return Reference to the newly created channel.
 * @param channelName Name of the channel to create.
 * @param channelKind Kind of the channel as registered with the CORBA naming service.
 * @param notifyFactoryName Name of the notification service as registered with the CORBA naming service.
 * @throws AcsJException Standard ACS Java exception.
 * @throws NameMapError (@TODO check in TAO code what this means!) 
 * @throws NameAlreadyUsed thrown if the channel of this name already exists.
 */
protected EventChannel createNotificationChannel(String channelName,String channelKind,String notifyFactoryName) throws AcsJException, NameAlreadyUsed, NameMapError {
  LOG_NC_ChannelCreated_ATTEMPT.log(m_logger,channelName,notifyFactoryName);
  EventChannel retValue=null;
  int channelId=-1;
  final String standardEventFactoryId=org.omg.CosNotifyChannelAdmin.EventChannelFactoryHelper.id();
  final String specialEventFactoryId=gov.sandia.NotifyMonitoringExt.EventChannelFactoryHelper.id();
  try {
    NameComponent[] t_NameFactory={new NameComponent(notifyFactoryName,"String_Node_Str")};
    org.omg.CORBA.Object notifyFactoryObj=null;
    EventChannelFactory notifyFactory=null;
    try {
      notifyFactoryObj=getNamingService().resolve(t_NameFactory);
    }
 catch (    org.omg.CosNaming.NamingContextPackage.NotFound ex) {
      String reason="String_Node_Str" + notifyFactoryName + "String_Node_Str"+ ex.why.toString();
      AcsJCORBAProblemEx ex2=new AcsJCORBAProblemEx();
      ex2.setInfo(reason);
      throw ex2;
    }
    try {
      notifyFactory=EventChannelFactoryHelper.narrow(notifyFactoryObj);
    }
 catch (    BAD_PARAM ex) {
      String errMsg="String_Node_Str" + notifyFactoryName + "String_Node_Str"+ specialEventFactoryId;
      if (notifyFactoryObj._is_a(standardEventFactoryId)) {
        errMsg+="String_Node_Str" + standardEventFactoryId + "String_Node_Str";
      }
 else {
        errMsg+="String_Node_Str" + standardEventFactoryId;
      }
      m_logger.warning(errMsg);
      AcsJNarrowFailedEx ex2=new AcsJNarrowFailedEx(ex);
      ex2.setNarrowType(specialEventFactoryId);
      throw ex2;
    }
    IntHolder channelIdHolder=new IntHolder();
    retValue=createNotifyChannel_internal(notifyFactory,m_channelProperties.configQofS(channelName),m_channelProperties.configAdminProps(channelName),channelName,channelIdHolder);
    if (retValue == null) {
      Throwable cause=new Throwable("String_Node_Str" + channelName + "String_Node_Str");
      throw new alma.ACSErrTypeJavaNative.wrappers.AcsJJavaLangEx(cause);
    }
    channelId=channelIdHolder.value;
    try {
      NameComponent[] t_NameChannel={new NameComponent(channelName,channelKind)};
      getNamingService().rebind(t_NameChannel,retValue);
    }
 catch (    org.omg.CosNaming.NamingContextPackage.NotFound ex) {
      String reason="String_Node_Str" + channelName + "String_Node_Str"+ ex.why.toString();
      AcsJCORBAProblemEx ex2=new AcsJCORBAProblemEx(ex);
      ex2.setInfo(reason);
      throw ex2;
    }
  }
 catch (  org.omg.CosNaming.NamingContextPackage.CannotProceed e) {
    Throwable cause=new Throwable(e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
catch (  org.omg.CosNaming.NamingContextPackage.InvalidName e) {
    Throwable cause=new Throwable(e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
catch (  org.omg.CosNotification.UnsupportedAdmin e) {
    Throwable cause=new Throwable("String_Node_Str" + channelName + "String_Node_Str"+ e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
catch (  org.omg.CosNotification.UnsupportedQoS e) {
    Throwable cause=new Throwable("String_Node_Str" + channelName + "String_Node_Str"+ e.getMessage());
    throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
  }
  LOG_NC_ChannelCreated_OK.log(m_logger,channelName,channelId,notifyFactoryName);
  return retValue;
}