Program: 112346
Project: 112346
Buggy source:
@Override protected void doPost(HttpServletRequest theReq,HttpServletResponse theResp) throws ServletException, IOException {
  if (DEBUGMODE) {
    myTemplateEngine.getCacheManager().clearAllCaches();
  }
  try {
    GenericClient client=(GenericClient)myCtx.newRestfulGenericClient(myServerBase);
    client.setKeepResponses(true);
    String method=theReq.getParameter("String_Node_Str");
    String prettyParam=theReq.getParameter("String_Node_Str");
    if ("String_Node_Str".equals(prettyParam)) {
      client.setPrettyPrint(true);
    }
    if ("String_Node_Str".equals(theReq.getParameter("String_Node_Str"))) {
      client.setEncoding(EncodingEnum.XML);
    }
 else     if ("String_Node_Str".equals(theReq.getParameter("String_Node_Str"))) {
      client.setEncoding(EncodingEnum.JSON);
    }
    String requestUrl;
    String action;
    String resultStatus;
    String resultBody;
    String resultSyntaxHighlighterClass;
    boolean returnsResource;
    try {
      if ("String_Node_Str".equals(method)) {
        returnsResource=true;
        client.conformance();
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(id)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        returnsResource=true;
        client.read(def.getImplementingClass(),new IdDt(id));
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(id)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        String versionId=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(versionId)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        returnsResource=true;
        client.vread(def.getImplementingClass(),new IdDt(id),new IdDt(versionId));
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(id)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        returnsResource=false;
        client.delete(def.getImplementingClass(),new IdDt(id));
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(id)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        returnsResource=false;
        client.history(def.getImplementingClass(),new IdDt(id));
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String resourceText=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(resourceText)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        IResource resource;
        if (client.getEncoding() == null || client.getEncoding() == EncodingEnum.XML) {
          resource=myCtx.newXmlParser().parseResource(def.getImplementingClass(),resourceText);
        }
 else {
          resource=myCtx.newJsonParser().parseResource(def.getImplementingClass(),resourceText);
        }
        returnsResource=false;
        client.create(resource);
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String resourceText=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(resourceText)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        IResource resource;
        if (client.getEncoding() == null || client.getEncoding() == EncodingEnum.XML) {
          resource=myCtx.newXmlParser().parseResource(def.getImplementingClass(),resourceText);
        }
 else {
          resource=myCtx.newJsonParser().parseResource(def.getImplementingClass(),resourceText);
        }
        returnsResource=false;
        client.validate(resource);
      }
 else       if ("String_Node_Str".equals(method)) {
        RuntimeResourceDefinition def=getResourceType(theReq);
        String resourceText=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(resourceText)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
        if (StringUtils.isBlank(id)) {
          theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
        }
        IResource resource;
        if (client.getEncoding() == null || client.getEncoding() == EncodingEnum.XML) {
          resource=myCtx.newXmlParser().parseResource(def.getImplementingClass(),resourceText);
        }
 else {
          resource=myCtx.newJsonParser().parseResource(def.getImplementingClass(),resourceText);
        }
        returnsResource=false;
        client.update(new IdDt(id),resource);
      }
 else       if ("String_Node_Str".equals(method)) {
        Map<String,List<IQueryParameterType>> params=new HashMap<String,List<IQueryParameterType>>();
        HashSet<String> hashSet=new HashSet<String>(theReq.getParameterMap().keySet());
        String paramName=null;
        IQueryParameterType paramValue=null;
        while (hashSet.isEmpty() == false) {
          String nextKey=hashSet.iterator().next();
          String nextValue=theReq.getParameter(nextKey);
          paramName=null;
          paramValue=null;
          if (nextKey.startsWith("String_Node_Str")) {
            int prefixLength="String_Node_Str".length();
            paramName=nextKey.substring(prefixLength + 2);
            String systemKey="String_Node_Str" + "String_Node_Str" + paramName;
            String valueKey="String_Node_Str" + "String_Node_Str" + paramName;
            String system=theReq.getParameter(systemKey);
            String value=theReq.getParameter(valueKey);
            paramValue=new IdentifierDt(system,value);
            hashSet.remove(systemKey);
            hashSet.remove(valueKey);
          }
 else           if (nextKey.startsWith("String_Node_Str")) {
            paramName=nextKey.substring("String_Node_Str".length());
            paramValue=new StringDt(nextValue);
          }
          if (paramName != null) {
            if (params.containsKey(paramName) == false) {
              params.put(paramName,new ArrayList<IQueryParameterType>());
            }
            params.get(paramName).add(paramValue);
          }
          hashSet.remove(nextKey);
        }
        RuntimeResourceDefinition def=getResourceType(theReq);
        returnsResource=false;
        client.search(def.getImplementingClass(),params);
      }
 else {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str" + method);
        return;
      }
    }
 catch (    BaseServerResponseException e) {
      ourLog.error("String_Node_Str",e);
      returnsResource=false;
    }
    HttpRequestBase lastRequest=client.getLastRequest();
    String requestBody=null;
    String requestSyntaxHighlighterClass=null;
    if (lastRequest instanceof HttpEntityEnclosingRequest) {
      HttpEntityEnclosingRequest lastEERequest=(HttpEntityEnclosingRequest)lastRequest;
      HttpEntity lastEE=lastEERequest.getEntity();
      if (lastEE.isRepeatable()) {
        StringWriter requestCapture=new StringWriter();
        lastEE.writeTo(new WriterOutputStream(requestCapture,"String_Node_Str"));
        requestBody=requestCapture.toString();
        ContentType ct=ContentType.get(lastEE);
        String mimeType=ct.getMimeType();
        EncodingEnum ctEnum=EncodingEnum.forContentType(mimeType);
        if (ctEnum == null) {
          requestSyntaxHighlighterClass="String_Node_Str";
        }
 else {
switch (ctEnum) {
case JSON:
            requestSyntaxHighlighterClass="String_Node_Str";
          break;
case XML:
default :
        requestSyntaxHighlighterClass="String_Node_Str";
      break;
  }
}
}
}
requestUrl=lastRequest.getURI().toASCIIString();
action=client.getLastRequest().getMethod();
resultStatus=client.getLastResponse().getStatusLine().toString();
resultBody=client.getLastResponseBody();
HttpResponse lastResponse=client.getLastResponse();
ContentType ct=ContentType.get(lastResponse.getEntity());
String mimeType=ct != null ? ct.getMimeType() : null;
EncodingEnum ctEnum=EncodingEnum.forContentType(mimeType);
String narrativeString="String_Node_Str";
if (ctEnum == null) {
resultSyntaxHighlighterClass="String_Node_Str";
}
 else {
switch (ctEnum) {
case JSON:
resultSyntaxHighlighterClass="String_Node_Str";
if (returnsResource) {
narrativeString=parseNarrative(ctEnum,resultBody);
}
break;
case XML:
default :
resultSyntaxHighlighterClass="String_Node_Str";
if (returnsResource) {
narrativeString=parseNarrative(ctEnum,resultBody);
}
break;
}
}
Header[] requestHeaders=applyHeaderFilters(lastRequest.getAllHeaders());
Header[] responseHeaders=applyHeaderFilters(lastResponse.getAllHeaders());
WebContext ctx=new WebContext(theReq,theResp,theReq.getServletContext(),theReq.getLocale());
ctx.setVariable("String_Node_Str",myServerBase);
ctx.setVariable("String_Node_Str",requestUrl);
ctx.setVariable("String_Node_Str",action);
ctx.setVariable("String_Node_Str",resultStatus);
ctx.setVariable("String_Node_Str",StringEscapeUtils.escapeHtml4(requestBody));
ctx.setVariable("String_Node_Str",requestSyntaxHighlighterClass);
ctx.setVariable("String_Node_Str",StringEscapeUtils.escapeHtml4(resultBody));
ctx.setVariable("String_Node_Str",resultSyntaxHighlighterClass);
ctx.setVariable("String_Node_Str",requestHeaders);
ctx.setVariable("String_Node_Str",responseHeaders);
ctx.setVariable("String_Node_Str",narrativeString);
myTemplateEngine.process(PUBLIC_TESTER_RESULT_HTML,ctx,theResp.getWriter());
}
 catch (Exception e) {
ourLog.error("String_Node_Str",e);
theResp.sendError(500,e.toString());
}
}

Fixed version (ground truth):
@Override protected void doPost(HttpServletRequest theReq,HttpServletResponse theResp) throws ServletException, IOException {
  if (DEBUGMODE) {
    myTemplateEngine.getCacheManager().clearAllCaches();
  }
  GenericClient client=(GenericClient)myCtx.newRestfulGenericClient(myServerBase);
  client.setKeepResponses(true);
  boolean returnsResource;
  try {
    String method=theReq.getParameter("String_Node_Str");
    String prettyParam=theReq.getParameter("String_Node_Str");
    if ("String_Node_Str".equals(prettyParam)) {
      client.setPrettyPrint(true);
    }
    if ("String_Node_Str".equals(theReq.getParameter("String_Node_Str"))) {
      client.setEncoding(EncodingEnum.XML);
    }
 else     if ("String_Node_Str".equals(theReq.getParameter("String_Node_Str"))) {
      client.setEncoding(EncodingEnum.JSON);
    }
    if ("String_Node_Str".equals(method)) {
      returnsResource=true;
      client.conformance();
    }
 else     if ("String_Node_Str".equals(method)) {
      RuntimeResourceDefinition def=getResourceType(theReq);
      String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
      if (StringUtils.isBlank(id)) {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
      }
      returnsResource=true;
      client.read(def.getImplementingClass(),new IdDt(id));
    }
 else     if ("String_Node_Str".equals(method)) {
      RuntimeResourceDefinition def=getResourceType(theReq);
      String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
      if (StringUtils.isBlank(id)) {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
      }
      String versionId=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
      if (StringUtils.isBlank(versionId)) {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
      }
      returnsResource=true;
      client.vread(def.getImplementingClass(),new IdDt(id),new IdDt(versionId));
    }
 else     if ("String_Node_Str".equals(method)) {
      RuntimeResourceDefinition def=getResourceType(theReq);
      String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
      if (StringUtils.isBlank(id)) {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
      }
      returnsResource=false;
      client.delete(def.getImplementingClass(),new IdDt(id));
    }
 else     if ("String_Node_Str".equals(method)) {
      RuntimeResourceDefinition def=getResourceType(theReq);
      String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
      if (StringUtils.isBlank(id)) {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
      }
      returnsResource=false;
      client.history(def.getImplementingClass(),new IdDt(id));
    }
 else     if ("String_Node_Str".equals(method)) {
      IResource resource=parseIncomingResource(theReq,theResp,client);
      returnsResource=false;
      client.create(resource);
    }
 else     if ("String_Node_Str".equals(method)) {
      IResource resource=parseIncomingResource(theReq,theResp,client);
      returnsResource=false;
      client.validate(resource);
    }
 else     if ("String_Node_Str".equals(method)) {
      String id=StringUtils.defaultString(theReq.getParameter("String_Node_Str"));
      if (StringUtils.isBlank(id)) {
        theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str");
      }
      IResource resource=parseIncomingResource(theReq,theResp,client);
      returnsResource=false;
      client.update(new IdDt(id),resource);
    }
 else     if ("String_Node_Str".equals(method)) {
      Map<String,List<IQueryParameterType>> params=new HashMap<String,List<IQueryParameterType>>();
      HashSet<String> hashSet=new HashSet<String>(theReq.getParameterMap().keySet());
      String paramName=null;
      IQueryParameterType paramValue=null;
      while (hashSet.isEmpty() == false) {
        String nextKey=hashSet.iterator().next();
        String nextValue=theReq.getParameter(nextKey);
        paramName=null;
        paramValue=null;
        if (nextKey.startsWith("String_Node_Str")) {
          int prefixLength="String_Node_Str".length();
          paramName=nextKey.substring(prefixLength + 2);
          String systemKey="String_Node_Str" + "String_Node_Str" + paramName;
          String valueKey="String_Node_Str" + "String_Node_Str" + paramName;
          String system=theReq.getParameter(systemKey);
          String value=theReq.getParameter(valueKey);
          paramValue=new IdentifierDt(system,value);
          hashSet.remove(systemKey);
          hashSet.remove(valueKey);
        }
 else         if (nextKey.startsWith("String_Node_Str")) {
          paramName=nextKey.substring("String_Node_Str".length());
          paramValue=new StringDt(nextValue);
        }
        if (paramName != null) {
          if (params.containsKey(paramName) == false) {
            params.put(paramName,new ArrayList<IQueryParameterType>());
          }
          params.get(paramName).add(paramValue);
        }
        hashSet.remove(nextKey);
      }
      RuntimeResourceDefinition def=getResourceType(theReq);
      returnsResource=false;
      client.search(def.getImplementingClass(),params);
    }
 else {
      theResp.sendError(Constants.STATUS_HTTP_400_BAD_REQUEST,"String_Node_Str" + method);
      return;
    }
  }
 catch (  DataFormatException e) {
    ourLog.error("String_Node_Str",e);
    returnsResource=false;
  }
catch (  Exception e) {
    ourLog.error("String_Node_Str",e);
    returnsResource=false;
  }
  try {
    HttpRequestBase lastRequest=client.getLastRequest();
    String requestBody=null;
    String requestSyntaxHighlighterClass=null;
    if (lastRequest instanceof HttpEntityEnclosingRequest) {
      HttpEntityEnclosingRequest lastEERequest=(HttpEntityEnclosingRequest)lastRequest;
      HttpEntity lastEE=lastEERequest.getEntity();
      if (lastEE.isRepeatable()) {
        StringWriter requestCapture=new StringWriter();
        lastEE.writeTo(new WriterOutputStream(requestCapture,"String_Node_Str"));
        requestBody=requestCapture.toString();
        ContentType ct=ContentType.get(lastEE);
        String mimeType=ct.getMimeType();
        EncodingEnum ctEnum=EncodingEnum.forContentType(mimeType);
        if (ctEnum == null) {
          requestSyntaxHighlighterClass="String_Node_Str";
        }
 else {
switch (ctEnum) {
case JSON:
            requestSyntaxHighlighterClass="String_Node_Str";
          break;
case XML:
default :
        requestSyntaxHighlighterClass="String_Node_Str";
      break;
  }
}
}
}
String resultSyntaxHighlighterClass;
String requestUrl=lastRequest != null ? lastRequest.getURI().toASCIIString() : null;
String action=client.getLastRequest() != null ? client.getLastRequest().getMethod() : null;
String resultStatus=client.getLastResponse() != null ? client.getLastResponse().getStatusLine().toString() : null;
String resultBody=client.getLastResponseBody();
HttpResponse lastResponse=client.getLastResponse();
ContentType ct=lastResponse != null ? ContentType.get(lastResponse.getEntity()) : null;
String mimeType=ct != null ? ct.getMimeType() : null;
EncodingEnum ctEnum=EncodingEnum.forContentType(mimeType);
String narrativeString="String_Node_Str";
if (ctEnum == null) {
resultSyntaxHighlighterClass="String_Node_Str";
}
 else {
switch (ctEnum) {
case JSON:
resultSyntaxHighlighterClass="String_Node_Str";
if (returnsResource) {
narrativeString=parseNarrative(ctEnum,resultBody);
}
break;
case XML:
default :
resultSyntaxHighlighterClass="String_Node_Str";
if (returnsResource) {
narrativeString=parseNarrative(ctEnum,resultBody);
}
break;
}
}
Header[] requestHeaders=lastRequest != null ? applyHeaderFilters(lastRequest.getAllHeaders()) : new Header[0];
Header[] responseHeaders=lastResponse != null ? applyHeaderFilters(lastResponse.getAllHeaders()) : new Header[0];
WebContext ctx=new WebContext(theReq,theResp,theReq.getServletContext(),theReq.getLocale());
ctx.setVariable("String_Node_Str",myServerBase);
ctx.setVariable("String_Node_Str",requestUrl);
ctx.setVariable("String_Node_Str",action);
ctx.setVariable("String_Node_Str",resultStatus);
ctx.setVariable("String_Node_Str",StringEscapeUtils.escapeHtml4(requestBody));
ctx.setVariable("String_Node_Str",requestSyntaxHighlighterClass);
ctx.setVariable("String_Node_Str",StringEscapeUtils.escapeHtml4(resultBody));
ctx.setVariable("String_Node_Str",resultSyntaxHighlighterClass);
ctx.setVariable("String_Node_Str",requestHeaders);
ctx.setVariable("String_Node_Str",responseHeaders);
ctx.setVariable("String_Node_Str",narrativeString);
myTemplateEngine.process(PUBLIC_TESTER_RESULT_HTML,ctx,theResp.getWriter());
}
 catch (Exception e) {
ourLog.error("String_Node_Str",e);
theResp.sendError(500,e.toString());
}
}