Program: 33256
Project: 33256
Buggy source:
private Document requestAnnotations(Document document,boolean disambiguate) throws GerbilException {
  Document resultDoc=new DocumentImpl(document.getText(),document.getDocumentURI());
  JSONObject parameters=new JSONObject();
  if (disambiguate) {
    JSONArray mentionsJson=new JSONArray();
    for (    Span span : document.getMarkings(Span.class)) {
      JSONObject mentionJson=new JSONObject();
      mentionJson.put(ENTITY_START_KEY,span.getStartPosition());
      mentionJson.put(ENTITY_END_KEY,span.getStartPosition() + span.getLength());
      mentionsJson.put(mentionJson);
    }
    parameters.put(SPANS_REQUEST_PARAMETER_KEY,mentionsJson);
  }
  parameters.put(TEXT_REQUEST_PARAMETER_KEY,document.getText());
  HttpPost request=createPostRequest(disambiguate ? disambiguateUrl : annotateUrl);
  request.addHeader("String_Node_Str","String_Node_Str");
  request.setEntity(new StringEntity(parameters.toString(),"String_Node_Str"));
  request.addHeader("String_Node_Str","String_Node_Str");
  HttpEntity entity=null;
  CloseableHttpResponse response=null;
  try {
    response=sendRequest(request);
    entity=response.getEntity();
    try {
      String content=IOUtils.toString(entity.getContent(),"String_Node_Str");
      JSONObject outObj=new JSONObject(content);
      JSONArray jsAnnotations=outObj.getJSONArray("String_Node_Str");
      int start;
      for (int i=0; i < jsAnnotations.length(); i++) {
        JSONObject js_ann=jsAnnotations.getJSONObject(i);
        if (js_ann.has(ENTITY_START_KEY) && js_ann.has(ENTITY_END_KEY) && js_ann.has(ENTITY_TITLE_KEY)) {
          start=js_ann.getInt(ENTITY_START_KEY);
          if (js_ann.has(ENTITY_CONFIDENCE_KEY)) {
            resultDoc.addMarking(new ScoredNamedEntity(start,js_ann.getInt(ENTITY_END_KEY) - start,Wikipedia2DBPediaTransformer.generateUriSet(js_ann.getString(ENTITY_TITLE_KEY)),js_ann.getDouble(ENTITY_CONFIDENCE_KEY)));
          }
 else {
            resultDoc.addMarking(new NamedEntity(start,js_ann.getInt(ENTITY_END_KEY) - start,Wikipedia2DBPediaTransformer.generateUriSet(js_ann.getString(ENTITY_TITLE_KEY))));
          }
        }
      }
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
      throw new GerbilException("String_Node_Str",e,ErrorTypes.UNEXPECTED_EXCEPTION);
    }
  }
  finally {
    if (entity != null) {
      try {
        EntityUtils.consume(entity);
      }
 catch (      IOException e1) {
      }
    }
    if (response != null) {
      try {
        response.close();
      }
 catch (      IOException e) {
      }
    }
    closeRequest(request);
  }
  return resultDoc;
}

Fixed version (ground truth):
private Document requestAnnotations(Document document,boolean disambiguate) throws GerbilException {
  Document resultDoc=new DocumentImpl(document.getText(),document.getDocumentURI());
  JSONObject parameters=new JSONObject();
  if (disambiguate) {
    JSONArray mentionsJson=new JSONArray();
    for (    Span span : document.getMarkings(Span.class)) {
      JSONObject mentionJson=new JSONObject();
      mentionJson.put(ENTITY_START_KEY,span.getStartPosition());
      mentionJson.put(ENTITY_END_KEY,span.getStartPosition() + span.getLength());
      mentionsJson.put(mentionJson);
    }
    parameters.put(SPANS_REQUEST_PARAMETER_KEY,mentionsJson);
  }
  parameters.put(TEXT_REQUEST_PARAMETER_KEY,document.getText());
  HttpPost request=createPostRequest(disambiguate ? disambiguateUrl : annotateUrl);
  request.setEntity(new StringEntity(parameters.toString(),"String_Node_Str"));
  request.addHeader(HttpHeaders.CONTENT_TYPE,"String_Node_Str");
  request.addHeader(HttpHeaders.ACCEPT,"String_Node_Str");
  request.addHeader(HttpHeaders.ACCEPT_CHARSET,"String_Node_Str");
  HttpEntity entity=null;
  CloseableHttpResponse response=null;
  try {
    response=sendRequest(request);
    entity=response.getEntity();
    try {
      String content=IOUtils.toString(entity.getContent(),"String_Node_Str");
      JSONObject outObj=new JSONObject(content);
      JSONArray jsAnnotations=outObj.getJSONArray("String_Node_Str");
      int start;
      for (int i=0; i < jsAnnotations.length(); i++) {
        JSONObject js_ann=jsAnnotations.getJSONObject(i);
        if (js_ann.has(ENTITY_START_KEY) && js_ann.has(ENTITY_END_KEY) && js_ann.has(ENTITY_TITLE_KEY)) {
          start=js_ann.getInt(ENTITY_START_KEY);
          if (js_ann.has(ENTITY_CONFIDENCE_KEY)) {
            resultDoc.addMarking(new ScoredNamedEntity(start,js_ann.getInt(ENTITY_END_KEY) - start,Wikipedia2DBPediaTransformer.generateUriSet(js_ann.getString(ENTITY_TITLE_KEY)),js_ann.getDouble(ENTITY_CONFIDENCE_KEY)));
          }
 else {
            resultDoc.addMarking(new NamedEntity(start,js_ann.getInt(ENTITY_END_KEY) - start,Wikipedia2DBPediaTransformer.generateUriSet(js_ann.getString(ENTITY_TITLE_KEY))));
          }
        }
      }
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str",e);
      throw new GerbilException("String_Node_Str",e,ErrorTypes.UNEXPECTED_EXCEPTION);
    }
  }
  finally {
    if (entity != null) {
      try {
        EntityUtils.consume(entity);
      }
 catch (      IOException e1) {
      }
    }
    if (response != null) {
      try {
        response.close();
      }
 catch (      IOException e) {
      }
    }
    closeRequest(request);
  }
  return resultDoc;
}