Program: 92415
Project: 92415
Buggy source:
/** 
 * This class fetch the SPARQL endpoint list from datahub using the datahub API 
 * @param epm 
 */
public static Collection<Endpoint> checkEndpointList(){
  Map<String,Endpoint> results=new HashMap<String,Endpoint>();
  try {
    HttpClientConnectionManager connMrg=new BasicHttpClientConnectionManager();
    CloseableHttpClient httpClient=HttpClients.custom().setConnectionManager(connMrg).build();
    HttpGet getRequest=new HttpGet("String_Node_Str");
    CloseableHttpResponse response=httpClient.execute(getRequest);
    if (response.getStatusLine().getStatusCode() != 200) {
      throw new RuntimeException("String_Node_Str" + response.getStatusLine().getStatusCode());
    }
    String respString=EntityUtils.toString(response.getEntity());
    response.close();
    JsonFactory factory=new JsonFactory();
    ObjectMapper mapper=new ObjectMapper(factory);
    JsonNode rootNode=mapper.readTree(respString);
    JsonNode res=rootNode.get("String_Node_Str");
    log.info("String_Node_Str",res.size());
    Iterator<JsonNode> iter=res.getElements();
    int c=1;
    Map<String,Set<String>> map=new HashMap<String,Set<String>>();
    while (iter.hasNext()) {
      JsonNode node=iter.next();
      String endpointURL=node.findPath("String_Node_Str").getTextValue().trim();
      String datasetId=node.findPath("String_Node_Str").getTextValue().trim();
      Set<String> s=map.get(endpointURL);
      if (s == null) {
        s=new HashSet<String>();
        map.put(endpointURL,s);
      }
      s.add(datasetId);
    }
    for (    Entry<String,Set<String>> ent : map.entrySet()) {
      String endpointURL=ent.getKey();
      if (endpointURL.length() == 0)       continue;
      Endpoint ep=results.get(endpointURL);
      if (ep == null) {
        try {
          ep=EndpointFactory.newEndpoint(new URI(endpointURL));
          List<Dataset> l=new ArrayList<Dataset>();
          ep.setDatasets(l);
          results.put(endpointURL,ep);
        }
 catch (        URISyntaxException e) {
          log.warn("String_Node_Str",e.getMessage());
        }
      }
      if (ent.getValue().size() != 0) {
        for (        String ds : ent.getValue()) {
          ep=checkForDataset(ep,ds,httpClient);
        }
      }
      if (c == 49) {
        System.out.println("String_Node_Str");
      }
      log.info("String_Node_Str",c++,ep);
    }
  }
 catch (  Exception e2) {
    log.warn("String_Node_Str",e2);
    e2.printStackTrace();
  }
  log.info("String_Node_Str",results.size());
  return results.values();
}

Fixed version (ground truth):
/** 
 * This class fetch the SPARQL endpoint list from datahub using the datahub API 
 * @param epm 
 */
public static Collection<Endpoint> checkEndpointList(){
  Map<String,Endpoint> results=new HashMap<String,Endpoint>();
  try {
    HttpClientConnectionManager connMrg=new BasicHttpClientConnectionManager();
    CloseableHttpClient httpClient=HttpClients.custom().setConnectionManager(connMrg).build();
    HttpGet getRequest=new HttpGet("String_Node_Str");
    CloseableHttpResponse response=httpClient.execute(getRequest);
    if (response.getStatusLine().getStatusCode() != 200) {
      throw new RuntimeException("String_Node_Str" + response.getStatusLine().getStatusCode());
    }
    String respString=EntityUtils.toString(response.getEntity());
    response.close();
    JsonFactory factory=new JsonFactory();
    ObjectMapper mapper=new ObjectMapper(factory);
    JsonNode rootNode=mapper.readTree(respString);
    JsonNode res=rootNode.get("String_Node_Str");
    log.info("String_Node_Str",res.size());
    Iterator<JsonNode> iter=res.getElements();
    int c=1;
    Map<String,Set<String>> map=new HashMap<String,Set<String>>();
    while (iter.hasNext()) {
      JsonNode node=iter.next();
      String endpointURL=node.findPath("String_Node_Str").getTextValue().trim();
      String datasetId=node.findPath("String_Node_Str").getTextValue().trim();
      Set<String> s=map.get(endpointURL);
      if (s == null) {
        s=new HashSet<String>();
        map.put(endpointURL,s);
      }
      s.add(datasetId);
    }
    for (    Entry<String,Set<String>> ent : map.entrySet()) {
      String endpointURL=ent.getKey();
      if (endpointURL.length() == 0)       continue;
      Endpoint ep=results.get(endpointURL);
      if (ep == null) {
        try {
          ep=EndpointFactory.newEndpoint(new URI(endpointURL));
          List<Dataset> l=new ArrayList<Dataset>();
          ep.setDatasets(l);
          results.put(endpointURL,ep);
        }
 catch (        URISyntaxException e) {
          log.warn("String_Node_Str",e.getMessage());
        }
      }
      if (ent.getValue().size() != 0) {
        for (        String ds : ent.getValue()) {
          ep=checkForDataset(ep,ds,httpClient);
          log.info("String_Node_Str",ep);
        }
      }
 else {
        System.err.println("String_Node_Str" + ep);
      }
      if (c == 49) {
        System.out.println("String_Node_Str");
      }
      log.info("String_Node_Str",c++,ep);
    }
  }
 catch (  Exception e2) {
    log.warn("String_Node_Str",e2);
    e2.printStackTrace();
  }
  log.info("String_Node_Str",results.size());
  return results.values();
}