Program: 112311
Project: 112311
Buggy source:
@Override public boolean handleException(RequestDetails theRequestDetails,Throwable theException,HttpServletRequest theRequest,HttpServletResponse theResponse) throws ServletException, IOException {
  BaseOperationOutcome oo=null;
  int statusCode=Constants.STATUS_HTTP_500_INTERNAL_ERROR;
  FhirContext ctx=theRequestDetails.getServer().getFhirContext();
  if (theException instanceof BaseServerResponseException) {
    oo=((BaseServerResponseException)theException).getOperationOutcome();
    statusCode=((BaseServerResponseException)theException).getStatusCode();
  }
  if (oo == null) {
    try {
      oo=(BaseOperationOutcome)ctx.getResourceDefinition("String_Node_Str").getImplementingClass().newInstance();
    }
 catch (    Exception e1) {
      ourLog.error("String_Node_Str",e1);
      throw new ServletException("String_Node_Str",e1);
    }
    BaseIssue issue=oo.addIssue();
    issue.getSeverityElement().setValue("String_Node_Str");
    if (theException instanceof InternalErrorException) {
      ourLog.error("String_Node_Str",theException);
      populateDetails(theException,issue);
    }
 else     if (theException instanceof BaseServerResponseException) {
      ourLog.warn("String_Node_Str",theException);
      BaseServerResponseException baseServerResponseException=(BaseServerResponseException)theException;
      statusCode=baseServerResponseException.getStatusCode();
      populateDetails(theException,issue);
      if (baseServerResponseException.getAdditionalMessages() != null) {
        for (        String next : baseServerResponseException.getAdditionalMessages()) {
          BaseIssue issue2=oo.addIssue();
          issue2.getSeverityElement().setValue("String_Node_Str");
          issue2.setDetails(next);
        }
      }
    }
 else {
      ourLog.error("String_Node_Str" + theException.toString(),theException);
      populateDetails(theException,issue);
      statusCode=Constants.STATUS_HTTP_500_INTERNAL_ERROR;
    }
  }
 else {
    ourLog.error("String_Node_Str",theException);
  }
  boolean requestIsBrowser=RestfulServer.requestIsBrowser(theRequest);
  String fhirServerBase=((Request)theRequestDetails).getFhirServerBase();
  RestfulServerUtils.streamResponseAsResource(theRequestDetails.getServer(),theResponse,oo,RestfulServerUtils.determineResponseEncodingNoDefault(theRequest),true,requestIsBrowser,NarrativeModeEnum.NORMAL,statusCode,false,fhirServerBase);
  theResponse.setStatus(statusCode);
  theRequestDetails.getServer().addHeadersToResponse(theResponse);
  theResponse.setContentType("String_Node_Str");
  theResponse.setCharacterEncoding("String_Node_Str");
  theResponse.getWriter().append(theException.getMessage());
  theResponse.getWriter().close();
  return false;
}

Fixed version (ground truth):
@Override public boolean handleException(RequestDetails theRequestDetails,Throwable theException,HttpServletRequest theRequest,HttpServletResponse theResponse) throws ServletException, IOException {
  ourLog.error("String_Node_Str",theException);
  BaseOperationOutcome oo=null;
  int statusCode=Constants.STATUS_HTTP_500_INTERNAL_ERROR;
  FhirContext ctx=theRequestDetails.getServer().getFhirContext();
  if (theException instanceof BaseServerResponseException) {
    oo=((BaseServerResponseException)theException).getOperationOutcome();
    statusCode=((BaseServerResponseException)theException).getStatusCode();
  }
  if (oo == null) {
    try {
      oo=(BaseOperationOutcome)ctx.getResourceDefinition("String_Node_Str").getImplementingClass().newInstance();
    }
 catch (    Exception e1) {
      ourLog.error("String_Node_Str",e1);
      throw new ServletException("String_Node_Str",e1);
    }
    BaseIssue issue=oo.addIssue();
    issue.getSeverityElement().setValue("String_Node_Str");
    if (theException instanceof InternalErrorException) {
      ourLog.error("String_Node_Str",theException);
      populateDetails(theException,issue);
    }
 else     if (theException instanceof BaseServerResponseException) {
      ourLog.warn("String_Node_Str",theException);
      BaseServerResponseException baseServerResponseException=(BaseServerResponseException)theException;
      statusCode=baseServerResponseException.getStatusCode();
      populateDetails(theException,issue);
      if (baseServerResponseException.getAdditionalMessages() != null) {
        for (        String next : baseServerResponseException.getAdditionalMessages()) {
          BaseIssue issue2=oo.addIssue();
          issue2.getSeverityElement().setValue("String_Node_Str");
          issue2.setDetails(next);
        }
      }
    }
 else {
      ourLog.error("String_Node_Str" + theException.toString(),theException);
      populateDetails(theException,issue);
      statusCode=Constants.STATUS_HTTP_500_INTERNAL_ERROR;
    }
  }
 else {
    ourLog.error("String_Node_Str",theException);
  }
  boolean requestIsBrowser=RestfulServer.requestIsBrowser(theRequest);
  String fhirServerBase=((Request)theRequestDetails).getFhirServerBase();
  RestfulServerUtils.streamResponseAsResource(theRequestDetails.getServer(),theResponse,oo,RestfulServerUtils.determineResponseEncodingNoDefault(theRequest),true,requestIsBrowser,NarrativeModeEnum.NORMAL,statusCode,false,fhirServerBase);
  theResponse.setStatus(statusCode);
  theRequestDetails.getServer().addHeadersToResponse(theResponse);
  theResponse.setContentType("String_Node_Str");
  theResponse.setCharacterEncoding("String_Node_Str");
  theResponse.getWriter().append(theException.getMessage());
  theResponse.getWriter().close();
  return false;
}