Program: 30463
Project: 30463
Buggy source:
/** 
 * Adds the given <tt>VirtualServer</tt> to this <tt>WebContainer</tt>. <p>If this <tt>WebContainer</tt> has already been started, the given <tt>virtualServer</tt> will be started as well.
 * @param virtualServer the <tt>VirtualServer</tt> to add
 * @throws ConfigException if a <tt>VirtualServer</tt> with thesame id has already been registered with this <tt>WebContainer</tt>
 * @throws GlassFishException if the given <tt>virtualServer</tt> failsto be started
 */
public void addVirtualServer(VirtualServer virtualServer) throws ConfigException, GlassFishException {
  if (!initialized) {
    init();
  }
  if (log.isLoggable(Level.INFO)) {
    log.info("String_Node_Str" + virtualServer.getID());
  }
  com.sun.enterprise.web.VirtualServer vs=(com.sun.enterprise.web.VirtualServer)engine.findChild(virtualServer.getID());
  if (vs != null) {
    throw new ConfigException("String_Node_Str" + virtualServer.getID() + "String_Node_Str");
  }
  Collection<WebListener> webListeners=virtualServer.getWebListeners();
  List<String> names=new ArrayList<String>();
  if ((webListeners != null) && (!webListeners.isEmpty())) {
    for (    WebListener listener : webListeners) {
      names.add(listener.getId());
    }
  }
 else {
    for (    NetworkListener networkListener : networkConfig.getNetworkListeners().getNetworkListener()) {
      names.add(networkListener.getName());
    }
    webListeners=listeners;
  }
  StringBuffer networkListeners=new StringBuffer("String_Node_Str");
  if (names.size() > 0) {
    networkListeners.append(names.get(0));
  }
  for (int i=1; i < names.size(); i++) {
    networkListeners.append("String_Node_Str");
    networkListeners.append(names.get(i));
  }
  String docRoot=null;
  if (virtualServer.getDocRoot() != null) {
    docRoot=virtualServer.getDocRoot().getPath();
  }
  String hostName=null;
  if (virtualServer.getConfig() != null) {
    hostName=virtualServer.getConfig().getHostNames();
  }
  final String root=docRoot;
  final String nl=networkListeners.toString();
  final String id=virtualServer.getID();
  final String hosts=hostName;
  try {
    ConfigSupport.apply(new SingleConfigCode<HttpService>(){
      public Object run(      HttpService param) throws PropertyVetoException, TransactionFailure {
        com.sun.enterprise.config.serverbeans.VirtualServer newVirtualServer=param.createChild(com.sun.enterprise.config.serverbeans.VirtualServer.class);
        newVirtualServer.setId(id);
        newVirtualServer.setNetworkListeners(nl);
        if (hosts != null) {
          newVirtualServer.setHosts(hosts);
        }
        Property property=newVirtualServer.createChild(Property.class);
        property.setName("String_Node_Str");
        property.setValue(root);
        newVirtualServer.getProperty().add(property);
        param.getVirtualServer().add(newVirtualServer);
        return newVirtualServer;
      }
    }
,httpService);
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  if ((webListeners != null) && (!webListeners.isEmpty())) {
    for (    WebListener listener : webListeners) {
      if (getWebListener(listener.getId()) == null) {
        addWebListener(listener,virtualServer.getID());
      }
    }
  }
  vs=(com.sun.enterprise.web.VirtualServer)engine.findChild(id);
  if (vs != null) {
    if (log.isLoggable(Level.INFO)) {
      log.info("String_Node_Str" + id + "String_Node_Str"+ docRoot+ "String_Node_Str"+ nl);
    }
    ((VirtualServerFacade)virtualServer).setVirtualSever(vs);
    vs.setNetworkListenerNames(names.toArray(new String[names.size()]));
  }
 else {
    log.severe("String_Node_Str" + id);
    throw new GlassFishException(new Exception("String_Node_Str" + id));
  }
}

Fixed version (ground truth):
/** 
 * Adds the given <tt>VirtualServer</tt> to this <tt>WebContainer</tt>. <p>If this <tt>WebContainer</tt> has already been started, the given <tt>virtualServer</tt> will be started as well.
 * @param virtualServer the <tt>VirtualServer</tt> to add
 * @throws ConfigException if a <tt>VirtualServer</tt> with thesame id has already been registered with this <tt>WebContainer</tt>
 * @throws GlassFishException if the given <tt>virtualServer</tt> failsto be started
 */
public void addVirtualServer(VirtualServer virtualServer) throws ConfigException, GlassFishException {
  if (!initialized) {
    init();
  }
  if (log.isLoggable(Level.INFO)) {
    log.info("String_Node_Str" + virtualServer.getID());
  }
  com.sun.enterprise.web.VirtualServer vs=(com.sun.enterprise.web.VirtualServer)engine.findChild(virtualServer.getID());
  if (vs != null) {
    throw new ConfigException("String_Node_Str" + virtualServer.getID() + "String_Node_Str");
  }
  Collection<WebListener> webListeners=virtualServer.getWebListeners();
  List<String> names=new ArrayList<String>();
  if ((webListeners != null) && (!webListeners.isEmpty())) {
    for (    WebListener listener : webListeners) {
      names.add(listener.getId());
    }
  }
 else {
    for (    NetworkListener networkListener : networkConfig.getNetworkListeners().getNetworkListener()) {
      names.add(networkListener.getName());
    }
    webListeners=listeners;
  }
  StringBuffer networkListeners=new StringBuffer("String_Node_Str");
  if (names.size() > 0) {
    networkListeners.append(names.get(0));
  }
  for (int i=1; i < names.size(); i++) {
    networkListeners.append("String_Node_Str");
    networkListeners.append(names.get(i));
  }
  String docRoot=null;
  if (virtualServer.getDocRoot() != null) {
    docRoot=virtualServer.getDocRoot().getPath();
  }
  String hostName=null;
  if (virtualServer.getConfig() != null) {
    hostName=virtualServer.getConfig().getHostNames();
  }
  final String root=docRoot;
  final String nl=networkListeners.toString();
  final String id=virtualServer.getID();
  final String hosts=hostName;
  try {
    ConfigSupport.apply(new SingleConfigCode<HttpService>(){
      public Object run(      HttpService param) throws PropertyVetoException, TransactionFailure {
        com.sun.enterprise.config.serverbeans.VirtualServer newVirtualServer=param.createChild(com.sun.enterprise.config.serverbeans.VirtualServer.class);
        newVirtualServer.setId(id);
        newVirtualServer.setNetworkListeners(nl);
        if (hosts != null) {
          newVirtualServer.setHosts(hosts);
        }
        Property property=newVirtualServer.createChild(Property.class);
        property.setName("String_Node_Str");
        property.setValue(root);
        newVirtualServer.getProperty().add(property);
        param.getVirtualServer().add(newVirtualServer);
        return newVirtualServer;
      }
    }
,httpService);
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
  if ((webListeners != null) && (!webListeners.isEmpty())) {
    for (    WebListener listener : webListeners) {
      if (getWebListener(listener.getId()) == null) {
        addWebListener(listener,virtualServer.getID());
      }
    }
  }
  vs=(com.sun.enterprise.web.VirtualServer)engine.findChild(id);
  if (vs != null) {
    if (log.isLoggable(Level.INFO)) {
      log.info("String_Node_Str" + id + "String_Node_Str"+ docRoot+ "String_Node_Str"+ nl);
    }
    if (virtualServer instanceof VirtualServerFacade) {
      ((VirtualServerFacade)virtualServer).setVirtualServer(vs);
    }
    vs.setNetworkListenerNames(names.toArray(new String[names.size()]));
  }
 else {
    log.severe("String_Node_Str" + id);
    throw new GlassFishException(new Exception("String_Node_Str" + id));
  }
}