Program: 94163
Project: 94163
Buggy source:
/** 
 * creates a new container instance.
 * @param description the container type description.
 * @param parameters the parameter passed to the container constructor.
 * @return the factored container instance.
 * @see org.eclipse.ecf.core.provider.IContainerInstantiator#createInstance(org.eclipse.ecf.core.ContainerTypeDescription,java.lang.Object[])
 */
public IContainer createInstance(final ContainerTypeDescription description,final Object[] parameters) throws ContainerCreateException {
  try {
    final RemoteOSGiService remoteOSGiService=Activator.getDefault().getRemoteOSGiService();
    String descriptionName=description.getName();
    boolean wss=descriptionName.equals(ROSGI_WEBSOCKETSS_CONFIG);
    boolean ws=(descriptionName.equals(ROSGI_WEBSOCKETS_CONFIG) || wss);
    Namespace ns=(wss ? R_OSGiWSSNamespace.getDefault() : ((ws) ? R_OSGiWSNamespace.getDefault() : R_OSGiNamespace.getDefault()));
    ID containerID=null;
    if (parameters == null) {
      String localHost=null;
      if (useHostname) {
        try {
          localHost=InetAddress.getLocalHost().getCanonicalHostName();
        }
 catch (        UnknownHostException e) {
          localHost="String_Node_Str";
        }
      }
      final String nsScheme=ns.getScheme();
      final String wsProtocol=(wss ? WSS_PROTOCOL : (ws ? WS_PROTOCOL : null));
      int listeningPort=remoteOSGiService.getListeningPort((wsProtocol != null) ? wsProtocol : nsScheme);
      int idPort=-1;
      if (WSS_PROTOCOL.equals(wsProtocol) && listeningPort != WSS_DEFAULT_PORT)       idPort=listeningPort;
 else       if (WS_PROTOCOL.equals(wsProtocol) && listeningPort != WS_DEFAULT_PORT)       idPort=listeningPort;
      String portStr=(idPort > 0 ? ("String_Node_Str" + idPort) : "String_Node_Str");
      containerID=createR_OSGiID(ns,new String(nsScheme + "String_Node_Str" + localHost+ portStr));
    }
 else     if (parameters.length > 0) {
      if (parameters[0] instanceof ID)       containerID=(ID)parameters[0];
 else       if (parameters[0] instanceof String)       containerID=createR_OSGiID(ns,(String)parameters[0]);
 else       if (parameters[0] instanceof Map) {
        Map params=(Map)parameters[0];
        String idStr=(String)params.get(ID_PROP);
        if (idStr == null)         throw new NullPointerException("String_Node_Str");
        containerID=createR_OSGiID(ns,idStr);
      }
    }
    if (containerID == null)     throw new ContainerCreateException("String_Node_Str" + Arrays.asList(parameters));
    if (wss)     return new R_OSGiWSRemoteServiceContainer(remoteOSGiService,containerID,true);
 else     if (ws)     return new R_OSGiWSRemoteServiceContainer(remoteOSGiService,containerID,false);
 else     return new R_OSGiRemoteServiceContainer(remoteOSGiService,containerID);
  }
 catch (  IDCreateException e) {
    throw new ContainerCreateException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * creates a new container instance.
 * @param description the container type description.
 * @param parameters the parameter passed to the container constructor.
 * @return the factored container instance.
 * @see org.eclipse.ecf.core.provider.IContainerInstantiator#createInstance(org.eclipse.ecf.core.ContainerTypeDescription,java.lang.Object[])
 */
public IContainer createInstance(final ContainerTypeDescription description,final Object[] parameters) throws ContainerCreateException {
  try {
    final RemoteOSGiService remoteOSGiService=Activator.getDefault().getRemoteOSGiService();
    String descriptionName=description.getName();
    boolean wss=descriptionName.equals(ROSGI_WEBSOCKETSS_CONFIG);
    boolean ws=(descriptionName.equals(ROSGI_WEBSOCKETS_CONFIG) || wss);
    Namespace ns=(wss ? R_OSGiWSSNamespace.getDefault() : ((ws) ? R_OSGiWSNamespace.getDefault() : R_OSGiNamespace.getDefault()));
    ID containerID=null;
    if (parameters == null) {
      String localHost="String_Node_Str";
      if (useHostname) {
        try {
          localHost=InetAddress.getLocalHost().getCanonicalHostName();
        }
 catch (        UnknownHostException e) {
        }
      }
      final String nsScheme=ns.getScheme();
      final String wsProtocol=(wss ? WSS_PROTOCOL : (ws ? WS_PROTOCOL : null));
      int listeningPort=remoteOSGiService.getListeningPort((wsProtocol != null) ? wsProtocol : nsScheme);
      int idPort=-1;
      if (WSS_PROTOCOL.equals(wsProtocol) && listeningPort != WSS_DEFAULT_PORT)       idPort=listeningPort;
 else       if (WS_PROTOCOL.equals(wsProtocol) && listeningPort != WS_DEFAULT_PORT)       idPort=listeningPort;
      String portStr=(idPort > 0 ? ("String_Node_Str" + idPort) : "String_Node_Str");
      containerID=createR_OSGiID(ns,new String(nsScheme + "String_Node_Str" + localHost+ portStr));
    }
 else     if (parameters.length > 0) {
      if (parameters[0] instanceof ID)       containerID=(ID)parameters[0];
 else       if (parameters[0] instanceof String)       containerID=createR_OSGiID(ns,(String)parameters[0]);
 else       if (parameters[0] instanceof Map) {
        Map params=(Map)parameters[0];
        String idStr=(String)params.get(ID_PROP);
        if (idStr == null)         throw new NullPointerException("String_Node_Str");
        containerID=createR_OSGiID(ns,idStr);
      }
    }
    if (containerID == null)     throw new ContainerCreateException("String_Node_Str" + Arrays.asList(parameters));
    if (wss)     return new R_OSGiWSRemoteServiceContainer(remoteOSGiService,containerID,true);
 else     if (ws)     return new R_OSGiWSRemoteServiceContainer(remoteOSGiService,containerID,false);
 else     return new R_OSGiRemoteServiceContainer(remoteOSGiService,containerID);
  }
 catch (  IDCreateException e) {
    throw new ContainerCreateException("String_Node_Str",e);
  }
}