Program: 25112
Project: 25112
Buggy source:
/** 
 * <p>Execute the given request in the TAP service by forwarding it to the appropriate resource.</p> <h3>Home page</h3> <p> If the appropriate resource is the home page, the request is not propagated and this class/resource displays directly the home page in the given response by calling   {@link #writeHomePage(HttpServletResponse,JobOwner)}. The default implementation of this function takes 2 cases into account: </p> <ol> <li><b>A custom home page has been specified</b> using   {@link #setHomePageURI(String)}. In this case, the content of the URL or file path will be directly copied into the HTTP response. The content type of the response must be specified by  {@link #setHomePageMimeType(String)} ; by default, it is "text/html".</li><li><b>Default home page.</b> When no custom home page has been specified, a default content is displayed. It is an HTML document which merely lists all resources available in this TAP service.</li> </ol> <h3>Error/Exception management</h3> <p> Only this resource (the root) should write any errors in the response. For that, it catches any  {@link Throwable} andwrite an appropriate message in the HTTP response. The format and the content of this message is designed by the  {@link ServiceErrorWriter}set in this class. By changing it, it is then possible to change, for instance, the format of the error responses. </p> <h3>Request ID &amp; Log</h3> <p> Each request is identified by a unique identifier (see   {@link #generateRequestID(HttpServletRequest)}). This ID is used only for logging purpose. Request and jobs/threads can then be associated more easily in the logs. Besides, every requests and their response are logged as INFO with this ID. </p>
 * @param request	Request of the user to execute in this TAP service.
 * @param response	Object in which the result of the request must be written.
 * @throws ServletException	If any grave/fatal error occurs.
 * @throws IOException		If any error occurs while reading or writing from or into a stream (and particularly the given request or response).
 */
public void executeRequest(final HttpServletRequest request,final HttpServletResponse response) throws ServletException, IOException {
  if (request == null || response == null)   return;
  final String reqID=generateRequestID(request);
  String[] resourcePath=(request.getPathInfo() == null) ? null : request.getPathInfo().split("String_Node_Str");
  final String resourceName=(resourcePath == null || resourcePath.length < 1) ? "String_Node_Str" : resourcePath[1].trim().toLowerCase();
  if (!resourceName.equalsIgnoreCase(ASync.RESOURCE_NAME))   getLogger().logHttp(LogLevel.INFO,request,reqID,null,null);
  if (tapBaseURL == null) {
    setTAPBaseURL(request);
    getLogger().logUWS(LogLevel.INFO,this,"String_Node_Str","String_Node_Str",null);
  }
  JobOwner owner=null;
  try {
    try {
      if (service.getUserIdentifier() != null)       owner=service.getUserIdentifier().extractUserId(new UWSUrl(request),request);
    }
 catch (    UWSException ue) {
      throw new TAPException(ue);
    }
    if (resourceName.equals("String_Node_Str"))     writeHomePage(response,owner);
 else {
      TAPResource res=resources.get(resourceName);
      if (res != null)       res.executeResource(request,response);
 else       throw new TAPException("String_Node_Str" + resourceName + "String_Node_Str",UWSException.NOT_IMPLEMENTED);
    }
    response.flushBuffer();
    if (!resourceName.equalsIgnoreCase(ASync.RESOURCE_NAME))     getLogger().logHttp(LogLevel.INFO,response,reqID,owner,"String_Node_Str" + UWSException.OK + "String_Node_Str"+ resourceName+ "String_Node_Str",null);
  }
 catch (  Throwable t) {
    errorWriter.writeError(t,response,request,reqID,owner,resourceName);
    getLogger().logHttp(LogLevel.ERROR,response,reqID,owner,"String_Node_Str" + response.getStatus() + "String_Node_Str"+ resourceName+ "String_Node_Str"+ t.getMessage(),t);
  }
 finally {
    if (resourceName.equalsIgnoreCase(Sync.RESOURCE_NAME) && service.getFactory().countFreeConnections() >= 1)     getASync().freeConnectionAvailable();
  }
}

Fixed version (ground truth):
/** 
 * <p>Execute the given request in the TAP service by forwarding it to the appropriate resource.</p> <h3>Home page</h3> <p> If the appropriate resource is the home page, the request is not propagated and this class/resource displays directly the home page in the given response by calling   {@link #writeHomePage(HttpServletResponse,JobOwner)}. The default implementation of this function takes 2 cases into account: </p> <ol> <li><b>A custom home page has been specified</b> using   {@link #setHomePageURI(String)}. In this case, the content of the URL or file path will be directly copied into the HTTP response. The content type of the response must be specified by  {@link #setHomePageMimeType(String)} ; by default, it is "text/html".</li><li><b>Default home page.</b> When no custom home page has been specified, a default content is displayed. It is an HTML document which merely lists all resources available in this TAP service.</li> </ol> <h3>Error/Exception management</h3> <p> Only this resource (the root) should write any errors in the response. For that, it catches any  {@link Throwable} andwrite an appropriate message in the HTTP response. The format and the content of this message is designed by the  {@link ServiceErrorWriter}set in this class. By changing it, it is then possible to change, for instance, the format of the error responses. </p> <h3>Request ID &amp; Log</h3> <p> Each request is identified by a unique identifier (see   {@link #generateRequestID(HttpServletRequest)}). This ID is used only for logging purpose. Request and jobs/threads can then be associated more easily in the logs. Besides, every requests and their response are logged as INFO with this ID. </p>
 * @param request	Request of the user to execute in this TAP service.
 * @param response	Object in which the result of the request must be written.
 * @throws ServletException	If any grave/fatal error occurs.
 * @throws IOException		If any error occurs while reading or writing from or into a stream (and particularly the given request or response).
 */
public void executeRequest(final HttpServletRequest request,final HttpServletResponse response) throws ServletException, IOException {
  if (request == null || response == null)   return;
  final String reqID=generateRequestID(request);
  String[] resourcePath=(request.getPathInfo() == null) ? null : request.getPathInfo().split("String_Node_Str");
  final String resourceName=(resourcePath == null || resourcePath.length < 1) ? "String_Node_Str" : resourcePath[1].trim().toLowerCase();
  if (!resourceName.equalsIgnoreCase(ASync.RESOURCE_NAME))   getLogger().logHttp(LogLevel.INFO,request,reqID,null,null);
  if (tapBaseURL == null) {
    setTAPBaseURL(request);
    getLogger().logUWS(LogLevel.INFO,this,"String_Node_Str","String_Node_Str",null);
  }
  JobOwner owner=null;
  try {
    try {
      if (service.getUserIdentifier() != null)       owner=service.getUserIdentifier().extractUserId(new UWSUrl(request),request);
    }
 catch (    UWSException ue) {
      throw new TAPException(ue);
    }
    if (resourceName.equals("String_Node_Str"))     writeHomePage(response,owner);
 else {
      TAPResource res=resources.get(resourceName);
      if (res != null)       res.executeResource(request,response);
 else       throw new TAPException("String_Node_Str" + resourceName + "String_Node_Str",UWSException.NOT_IMPLEMENTED);
    }
    response.flushBuffer();
    if (!resourceName.equalsIgnoreCase(ASync.RESOURCE_NAME))     getLogger().logHttp(LogLevel.INFO,response,reqID,owner,"String_Node_Str" + UWSException.OK + "String_Node_Str"+ resourceName+ "String_Node_Str",null);
  }
 catch (  Throwable t) {
    errorWriter.writeError(t,response,request,reqID,owner,resourceName);
    getLogger().logHttp(LogLevel.ERROR,response,reqID,owner,"String_Node_Str" + response.getStatus() + "String_Node_Str"+ resourceName+ "String_Node_Str",t);
  }
 finally {
    if (resourceName.equalsIgnoreCase(Sync.RESOURCE_NAME) && service.getFactory().countFreeConnections() >= 1)     getASync().freeConnectionAvailable();
  }
}