Program: 72619
Project: 72619
Buggy source:
/** 
 * Collect servlets from all model objects implementing HttpService and WebSocketService and start the web server in a new thread. <p> In the current implementation, servlets must be registered before the Jetty server starts.  Servlets are not allowed to be added to a running ContextHandler.  Currently, the Jetty server is started once and runs until the model finishes executing.  It would also be possible to pause the server, add a servlet, and restart the server, which would allow a model to dynamically add servlets.  This might cause strange behavior to an outside observer, however, since some HttpRequests could fail if a servlet has not been loaded yet. References: <ul> <li> <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty">http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty</a></li> <li> <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty">http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty</a></li> <li> <a href="http://draconianoverlord.com/2009/01/10/war-less-dev-with-jetty.html">http://draconianoverlord.com/2009/01/10/war-less-dev-with-jetty.html</a></li> </ul>
 * @exception IllegalActionException Not thrown in this base class.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  if (_debugging) {
    _debug("String_Node_Str");
  }
  HashSet<WebSocketService> servicesToOpen=new HashSet();
  int preferredPortValue=WebServerUtilities.DEFAULT_PORT_NUMBER;
  if (preferredPort != null && !preferredPort.getExpression().isEmpty()) {
    preferredPortValue=Integer.parseInt(preferredPort.getExpression());
    _dynamicPortSelection=false;
  }
 else {
    _dynamicPortSelection=true;
  }
  if (_serverManager == null) {
    _serverManager=WebServerManager.getInstance();
  }
  String modelName=getFullName();
  String applicationPathString="String_Node_Str";
  if (applicationPath != null) {
    if (applicationPath.getExpression().startsWith("String_Node_Str")) {
      applicationPathString=applicationPath.getExpression();
    }
 else {
      applicationPathString="String_Node_Str" + applicationPath.getExpression();
    }
  }
  try {
    _appInfo=new WebApplicationInfo(modelName,applicationPathString,temporaryFileLocation);
  }
 catch (  Exception e) {
    throw new IllegalActionException(this,e,"String_Node_Str");
  }
  NamedObj container=getContainer();
  if (!(container instanceof CompositeEntity)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  List<Entity> entities=((CompositeEntity)container).allAtomicEntityList();
  for (  Entity entity : entities) {
    if (entity instanceof HttpService) {
      HttpService service=(HttpService)entity;
      service.setWebServer(this);
      if (_debugging) {
        _debug("String_Node_Str" + entity.getFullName());
      }
      URI path=service.getRelativePath();
      try {
        _appInfo.addServletInfo(path,service.getServlet());
      }
 catch (      Exception e) {
        throw new IllegalActionException(this,"String_Node_Str" + entity.getName() + "String_Node_Str"+ path+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      }
    }
 else     if (entity instanceof WebSocketService) {
      WebSocketService service=(WebSocketService)entity;
      boolean isLocal=!WebSocketEndpointManager.isRemoteURI(service.getRelativePath());
      if (isLocal && service.isClient()) {
        servicesToOpen.add(service);
      }
      if (_debugging) {
        _debug("String_Node_Str" + entity.getFullName());
      }
      if (isLocal) {
        URI path=service.getRelativePath();
        try {
          _appInfo.addSocketInfo(path,entity);
        }
 catch (        Exception e) {
          throw new IllegalActionException(this,"String_Node_Str" + entity.getName() + "String_Node_Str"+ path+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
        }
      }
    }
  }
  LinkedHashSet<Resource> resourceLocations=new LinkedHashSet<Resource>();
  List<FileParameter> bases=attributeList(FileParameter.class);
  HashSet<URL> seen=new HashSet<URL>();
  for (  FileParameter base : bases) {
    if (base.getExpression() != null && !base.getExpression().isEmpty()) {
      try {
        String expression=base.getExpression();
        if (expression.startsWith("String_Node_Str")) {
          expression=expression.substring(6);
        }
        URL baseURL;
        if (expression.startsWith("String_Node_Str")) {
          baseURL=base.asURL();
        }
 else         if (this.getClass().getClassLoader().getResource(expression) != null) {
          baseURL=new URL(this.getClass().getClassLoader().getResource(expression).toExternalForm());
        }
 else {
          baseURL=base.asURL();
        }
        if (baseURL != null) {
          URL baseAsURL=base.asURL();
          if (seen.contains(baseAsURL)) {
            continue;
          }
          seen.add(baseAsURL);
          if (_debugging) {
            _debug("String_Node_Str" + baseAsURL);
          }
          String stringURL=baseAsURL.toExternalForm();
          if (!stringURL.endsWith("String_Node_Str")) {
            stringURL=stringURL + "String_Node_Str";
          }
          resourceLocations.add(Resource.newResource(stringURL));
        }
      }
 catch (      IOException e3) {
        throw new IllegalActionException(this,"String_Node_Str" + base.stringValue());
      }
    }
  }
  try {
    _appInfo.addResourceInfo(new URI(resourcePath.stringValue()),resourceLocations);
  }
 catch (  URISyntaxException e) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
catch (  Exception e2) {
    throw new IllegalActionException(this,e2,"String_Node_Str");
  }
  try {
    int actualPort=_serverManager.register(_appInfo,preferredPortValue,_dynamicPortSelection);
    if (actualPort != -1) {
      deployedPort.setExpression(Integer.toString(actualPort));
      deployedPort.validate();
    }
    _endpointManager.openLocalServices(servicesToOpen,actualPort);
  }
 catch (  Exception e) {
    throw new IllegalActionException(this,e,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Collect servlets from all model objects implementing HttpService and WebSocketService and start the web server in a new thread. <p> In the current implementation, servlets must be registered before the Jetty server starts.  Servlets are not allowed to be added to a running ContextHandler.  Currently, the Jetty server is started once and runs until the model finishes executing.  It would also be possible to pause the server, add a servlet, and restart the server, which would allow a model to dynamically add servlets.  This might cause strange behavior to an outside observer, however, since some HttpRequests could fail if a servlet has not been loaded yet. References: <ul> <li> <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty">http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty</a></li> <li> <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty">http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty</a></li> <li> <a href="http://draconianoverlord.com/2009/01/10/war-less-dev-with-jetty.html">http://draconianoverlord.com/2009/01/10/war-less-dev-with-jetty.html</a></li> </ul>
 * @exception IllegalActionException Not thrown in this base class.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  if (_debugging) {
    _debug("String_Node_Str");
  }
  if (_endpointManager == null) {
    _endpointManager=WebSocketEndpointManager.getInstance();
  }
  HashSet<WebSocketService> servicesToOpen=new HashSet();
  int preferredPortValue=WebServerUtilities.DEFAULT_PORT_NUMBER;
  if (preferredPort != null && !preferredPort.getExpression().isEmpty()) {
    preferredPortValue=Integer.parseInt(preferredPort.getExpression());
    _dynamicPortSelection=false;
  }
 else {
    _dynamicPortSelection=true;
  }
  if (_serverManager == null) {
    _serverManager=WebServerManager.getInstance();
  }
  String modelName=getFullName();
  String applicationPathString="String_Node_Str";
  if (applicationPath != null) {
    if (applicationPath.getExpression().startsWith("String_Node_Str")) {
      applicationPathString=applicationPath.getExpression();
    }
 else {
      applicationPathString="String_Node_Str" + applicationPath.getExpression();
    }
  }
  try {
    _appInfo=new WebApplicationInfo(modelName,applicationPathString,temporaryFileLocation);
  }
 catch (  Exception e) {
    throw new IllegalActionException(this,e,"String_Node_Str");
  }
  NamedObj container=getContainer();
  if (!(container instanceof CompositeEntity)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  List<Entity> entities=((CompositeEntity)container).allAtomicEntityList();
  for (  Entity entity : entities) {
    if (entity instanceof HttpService) {
      HttpService service=(HttpService)entity;
      service.setWebServer(this);
      if (_debugging) {
        _debug("String_Node_Str" + entity.getFullName());
      }
      URI path=service.getRelativePath();
      try {
        _appInfo.addServletInfo(path,service.getServlet());
      }
 catch (      Exception e) {
        throw new IllegalActionException(this,"String_Node_Str" + entity.getName() + "String_Node_Str"+ path+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
      }
    }
 else     if (entity instanceof WebSocketService) {
      WebSocketService service=(WebSocketService)entity;
      boolean isLocal=!WebSocketEndpointManager.isRemoteURI(service.getRelativePath());
      if (isLocal && service.isClient()) {
        servicesToOpen.add(service);
      }
      if (_debugging) {
        _debug("String_Node_Str" + entity.getFullName());
      }
      if (isLocal) {
        URI path=service.getRelativePath();
        try {
          _appInfo.addSocketInfo(path,entity);
        }
 catch (        Exception e) {
          throw new IllegalActionException(this,"String_Node_Str" + entity.getName() + "String_Node_Str"+ path+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
        }
      }
    }
  }
  LinkedHashSet<Resource> resourceLocations=new LinkedHashSet<Resource>();
  List<FileParameter> bases=attributeList(FileParameter.class);
  HashSet<URL> seen=new HashSet<URL>();
  for (  FileParameter base : bases) {
    if (base.getExpression() != null && !base.getExpression().isEmpty()) {
      try {
        String expression=base.getExpression();
        if (expression.startsWith("String_Node_Str")) {
          expression=expression.substring(6);
        }
        URL baseURL;
        if (expression.startsWith("String_Node_Str")) {
          baseURL=base.asURL();
        }
 else         if (this.getClass().getClassLoader().getResource(expression) != null) {
          baseURL=new URL(this.getClass().getClassLoader().getResource(expression).toExternalForm());
        }
 else {
          baseURL=base.asURL();
        }
        if (baseURL != null) {
          URL baseAsURL=base.asURL();
          if (seen.contains(baseAsURL)) {
            continue;
          }
          seen.add(baseAsURL);
          if (_debugging) {
            _debug("String_Node_Str" + baseAsURL);
          }
          String stringURL=baseAsURL.toExternalForm();
          if (!stringURL.endsWith("String_Node_Str")) {
            stringURL=stringURL + "String_Node_Str";
          }
          resourceLocations.add(Resource.newResource(stringURL));
        }
      }
 catch (      IOException e3) {
        throw new IllegalActionException(this,"String_Node_Str" + base.stringValue());
      }
    }
  }
  try {
    _appInfo.addResourceInfo(new URI(resourcePath.stringValue()),resourceLocations);
  }
 catch (  URISyntaxException e) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
catch (  Exception e2) {
    throw new IllegalActionException(this,e2,"String_Node_Str");
  }
  try {
    int actualPort=_serverManager.register(_appInfo,preferredPortValue,_dynamicPortSelection);
    if (actualPort != -1) {
      deployedPort.setExpression(Integer.toString(actualPort));
      deployedPort.validate();
    }
    _endpointManager.openLocalServices(servicesToOpen,actualPort);
  }
 catch (  Exception e) {
    throw new IllegalActionException(this,e,"String_Node_Str");
  }
}