nus-yam/ex-repair huggingface dataset:
Program: 13093
Project: 13093
Buggy source:
void doDiscoverNodes(List<ConnectionDetails> connectionDetailsList,Map<String,Node> nodes,Node initialNode,int level,int depth){
  for (  ConnectionDetails connectionDetails : connectionDetailsList) {
    String connectionType=connectionDetails.getConnectionType();
    NodeDiscoverer nodeDiscoverer=nodeDiscoverers.get(connectionType);
    if (level == depth)     return;
    if (nodeDiscoverFilter != null && nodeDiscoverFilter.match(connectionDetails))     return;
    NodeDiscoveryResult discoveryResult=nodeDiscoverer.discover(connectionDetails);
    fireNodeDiscoveredEvent(discoveryResult);
    String nodeId=discoveryResult.getNodeId();
    logger.info("String_Node_Str" + nodeId);
    logger.debug("String_Node_Str" + connectionDetails);
    Node currentNode=nodes.get(nodeId);
    if (currentNode == null) {
      currentNode=new Node(nodeId,connectionDetailsList);
      nodes.put(nodeId,currentNode);
    }
 else {
      logger.debug("String_Node_Str" + currentNode.getId() + "String_Node_Str");
      return;
    }
    if (initialNode != null)     initialNode.addNeighbour(currentNode);
    List<ConnectionDetails> neighboursConnectionDetails=discoveryResult.getNeighboursConnectionDetails();
    doDiscoverNodes(neighboursConnectionDetails,nodes,currentNode,level + 1,depth);
  }
}

Fixed version (ground truth):
void doDiscoverNodes(List<ConnectionDetails> connectionDetailsList,Map<String,Node> nodes,Node initialNode,int level,int depth){
  for (  ConnectionDetails connectionDetails : connectionDetailsList) {
    String connectionType=connectionDetails.getConnectionType();
    NodeDiscoverer nodeDiscoverer=nodeDiscoverers.get(connectionType);
    if (level == depth)     return;
    if (nodeDiscoverFilter != null && nodeDiscoverFilter.match(connectionDetails))     return;
    NodeDiscoveryResult discoveryResult=nodeDiscoverer.discover(connectionDetails);
    fireNodeDiscoveredEvent(discoveryResult);
    String nodeId=discoveryResult.getNodeId();
    Node currentNode=nodes.get(nodeId);
    if (currentNode == null) {
      if (logger.getLevel() == Level.INFO) {
        logger.info("String_Node_Str" + nodeId + "String_Node_Str");
      }
 else {
        logger.debug("String_Node_Str" + nodeId + "String_Node_Str"+ connectionDetails);
      }
      currentNode=new Node(nodeId,Arrays.asList(connectionDetails));
      nodes.put(nodeId,currentNode);
    }
 else {
      logger.debug("String_Node_Str" + currentNode.getId() + "String_Node_Str");
      return;
    }
    if (initialNode != null)     initialNode.addNeighbour(currentNode);
    List<ConnectionDetails> neighboursConnectionDetails=discoveryResult.getNeighboursConnectionDetails();
    logger.debug("String_Node_Str" + neighboursConnectionDetails);
    doDiscoverNodes(neighboursConnectionDetails,nodes,currentNode,level + 1,depth);
  }
}
Program: 13094
Project: 13094
Buggy source:
@Override public NodeDiscoveryResult discover(ConnectionDetails connectionDetails){
  String node=connectionDetails.getParam("String_Node_Str");
  NodeDiscoveryResult result=new NodeDiscoveryResult();
  result.setNodeId(node);
  Set<ConnectionDetails> neighbours=new HashSet<ConnectionDetails>();
  for (  Pair<String,String> link : links) {
    String neighbour=null;
    if (link.getFirst().equals(node)) {
      neighbour=link.getSecond();
    }
 else {
      neighbour=link.getFirst();
    }
    if (neighbour != null) {
      ConnectionDetails conn=new ConnectionDetails("String_Node_Str");
      conn.put("String_Node_Str",neighbour);
      neighbours.add(conn);
    }
  }
  result.setNeighboursConnectionDetails(Arrays.asList(neighbours.toArray(new ConnectionDetails[0])));
  return result;
}

Fixed version (ground truth):
@Override public NodeDiscoveryResult discover(ConnectionDetails connectionDetails){
  String node=connectionDetails.getParam("String_Node_Str");
  NodeDiscoveryResult result=new NodeDiscoveryResult();
  result.setNodeId(node);
  Set<ConnectionDetails> neighbours=new HashSet<ConnectionDetails>();
  for (  Pair<String,String> link : links) {
    String neighbour;
    if (link.getFirst().equals(node)) {
      neighbour=link.getSecond();
    }
 else     if (link.getSecond().equals(node)) {
      neighbour=link.getFirst();
    }
 else {
      continue;
    }
    if (neighbour != null) {
      ConnectionDetails conn=new ConnectionDetails("String_Node_Str");
      conn.put("String_Node_Str",neighbour);
      neighbours.add(conn);
    }
  }
  result.setNeighboursConnectionDetails(Arrays.asList(neighbours.toArray(new ConnectionDetails[0])));
  return result;
}
Program: 13095
Project: 13095
Buggy source:
public MockNetworkDiscoverer(){
  networkNodes=new HashSet<String>(Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  links=new HashSet<Pair<String,String>>();
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
public MockNetworkDiscoverer(){
  networkNodes=new HashSet<String>(Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  links=new HashSet<Pair<String,String>>();
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
  links.add(new Pair<String,String>("String_Node_Str","String_Node_Str"));
}
Program: 13096
Project: 13096
Buggy source:
public static void main1(String[] args){
  ConnectionDetails connectionDetails=new ConnectionDetails();
  ;
  connectionDetails.setConnectionType("String_Node_Str");
  Map<String,String> params=new HashMap();
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  connectionDetails.setParams(params);
  NetworkDiscoverer discoverer=new NetworkDiscoverer();
  Map<String,Node> result=discoverer.discoverNodes(Arrays.asList(connectionDetails));
  System.out.println(result);
}

Fixed version (ground truth):
public static void main1(String[] args){
  ConnectionDetails connectionDetails=new ConnectionDetails();
  ;
  connectionDetails.setConnectionType("String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  NetworkDiscoverer discoverer=new NetworkDiscoverer();
  Map<String,Node> result=discoverer.discoverNodes(Arrays.asList(connectionDetails));
  System.out.println(result);
}
Program: 13097
Project: 13097
Buggy source:
public static void main(String[] args){
  ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext("String_Node_Str");
  NetworkDiscoverer discoverer=applicationContext.getBean(NetworkDiscoverer.class);
  ConnectionDetails connectionDetails=new ConnectionDetails();
  connectionDetails.setConnectionType("String_Node_Str");
  Map<String,String> params=new HashMap<String,String>();
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  params.put("String_Node_Str","String_Node_Str");
  connectionDetails.setParams(params);
  Map<String,Node> result=discoverer.discoverNodes(Arrays.asList(connectionDetails));
  System.out.println(result);
}

Fixed version (ground truth):
public static void main(String[] args){
  ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext("String_Node_Str");
  NetworkDiscoverer discoverer=applicationContext.getBean(NetworkDiscoverer.class);
  ConnectionDetails connectionDetails=new ConnectionDetails();
  connectionDetails.setConnectionType("String_Node_Str");
  Map<String,String> params=new HashMap<String,String>();
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  connectionDetails.put("String_Node_Str","String_Node_Str");
  Map<String,Node> result=discoverer.discoverNodes(Arrays.asList(connectionDetails));
  System.out.println(result);
}
Program: 13098
Project: 13098
Buggy source:
public Map<String,Node> discoverNodes(List<ConnectionDetails> connectionDetailsList){
  this.filter=filter;
  Map<String,Node> nodes=new HashMap<String,Node>();
  doDiscoverNodes(connectionDetailsList,nodes,null);
  return nodes;
}

Fixed version (ground truth):
public Map<String,Node> discoverNodes(List<ConnectionDetails> connectionDetailsList,int depth){
  Map<String,Node> nodes=new HashMap<String,Node>();
  doDiscoverNodes(connectionDetailsList,nodes,null,0,depth);
  return nodes;
}
Program: 13099
Project: 13099
Buggy source:
private void doDiscoverNodes(List<ConnectionDetails> connectionDetailsList,Map<String,Node> nodes,Node initialNode){
  for (  ConnectionDetails connectionDetails : connectionDetailsList) {
    String connectionType=connectionDetails.getConnectionType();
    NodeDiscoverer nodeDiscoverer=nodeDiscoverers.get(connectionType);
    boolean stopDiscovery=filter.match(connectionDetails);
    if (stopDiscovery)     return;
    NodeDiscoveryResult discoveryResult=nodeDiscoverer.discover(connectionDetails);
    String nodeId=discoveryResult.getNodeId();
    System.out.println("String_Node_Str" + nodeId);
    Node currentNode=nodes.get(nodeId);
    if (currentNode == null) {
      currentNode=new Node(nodeId,connectionDetailsList);
      nodes.put(nodeId,currentNode);
    }
    if (initialNode != null) {
      initialNode.addNeighbour(currentNode);
    }
    List<ConnectionDetails> neighboursConnectionDetails=discoveryResult.getNeighboursConnectionDetails();
    doDiscoverNodes(neighboursConnectionDetails,nodes,currentNode);
  }
}

Fixed version (ground truth):
void doDiscoverNodes(List<ConnectionDetails> connectionDetailsList,Map<String,Node> nodes,Node initialNode,int level,int depth){
  for (  ConnectionDetails connectionDetails : connectionDetailsList) {
    String connectionType=connectionDetails.getConnectionType();
    NodeDiscoverer nodeDiscoverer=nodeDiscoverers.get(connectionType);
    if (level == depth)     return;
    if (filter != null) {
      boolean stopDiscovery=filter.match(connectionDetails);
      if (stopDiscovery)       return;
    }
    NodeDiscoveryResult discoveryResult=nodeDiscoverer.discover(connectionDetails);
    String nodeId=discoveryResult.getNodeId();
    System.out.println("String_Node_Str" + nodeId);
    Node currentNode=nodes.get(nodeId);
    if (currentNode == null) {
      currentNode=new Node(nodeId,connectionDetailsList);
      nodes.put(nodeId,currentNode);
    }
 else {
      System.out.println("String_Node_Str" + currentNode.getId() + "String_Node_Str");
      return;
    }
    if (initialNode != null) {
      initialNode.addNeighbour(currentNode);
    }
    List<ConnectionDetails> neighboursConnectionDetails=discoveryResult.getNeighboursConnectionDetails();
    doDiscoverNodes(neighboursConnectionDetails,nodes,currentNode,level + 1,depth);
  }
}
Program: 13100
Project: 13100
Buggy source:
@Override public boolean match(ConnectionDetails details){
  String host=details.getParams().get("String_Node_Str");
  for (  String notMatch : notMatches) {
    String propertyName=notMatch.substring(0,notMatch.indexOf("String_Node_Str"));
    String propVal=host;
    String notMatchVal=notMatch.substring(notMatch.indexOf("String_Node_Str") + 1);
    logger.debug("String_Node_Str" + propertyName + "String_Node_Str"+ propVal+ "String_Node_Str"+ notMatchVal);
    if (propVal != null && propVal.matches(notMatchVal)) {
      return false;
    }
  }
  for (  String match : matches) {
    String propertyName=match.substring(0,match.indexOf("String_Node_Str"));
    String propVal=host;
    String matchVal=match.substring(match.indexOf("String_Node_Str") + 1);
    logger.debug("String_Node_Str" + propertyName + "String_Node_Str"+ propVal+ "String_Node_Str"+ matchVal);
    if (propVal != null && propVal.matches(matchVal)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean match(ConnectionDetails details){
  String host=details.getParam("String_Node_Str");
  for (  String notMatch : notMatches) {
    String propertyName=notMatch.substring(0,notMatch.indexOf("String_Node_Str"));
    String propVal=host;
    String notMatchVal=notMatch.substring(notMatch.indexOf("String_Node_Str") + 1);
    logger.debug("String_Node_Str" + propertyName + "String_Node_Str"+ propVal+ "String_Node_Str"+ notMatchVal);
    if (propVal != null && propVal.matches(notMatchVal)) {
      return false;
    }
  }
  for (  String match : matches) {
    String propertyName=match.substring(0,match.indexOf("String_Node_Str"));
    String propVal=host;
    String matchVal=match.substring(match.indexOf("String_Node_Str") + 1);
    logger.debug("String_Node_Str" + propertyName + "String_Node_Str"+ propVal+ "String_Node_Str"+ matchVal);
    if (propVal != null && propVal.matches(matchVal)) {
      return true;
    }
  }
  return false;
}
Program: 13102
Project: 13102
Buggy source:
private List<ConnectionDetails> createNeighbourConnectionDetails(ConnectionDetails connectionDetails,Map<String,String> params,List<DeviceNeighbour> neighbours){
  List<ConnectionDetails> neighboursConnDetails=new ArrayList<ConnectionDetails>();
  for (  DeviceNeighbour neighbour : neighbours) {
    params.put("String_Node_Str",neighbour.getDeviceType());
    if (neighbour.getStatus()) {
      params.put("String_Node_Str",neighbour.getHostName());
      params.put("String_Node_Str",neighbour.getIpAddress().getIpAddress());
      params.put("String_Node_Str",neighbour.getIpAddress().getNetMask());
      params.put("String_Node_Str","String_Node_Str" + neighbour.getROCommunity());
      ConnectionDetails neighbourConnectionDetails=new ConnectionDetails();
      neighbourConnectionDetails.setConnectionType("String_Node_Str");
      neighbourConnectionDetails.setParams(params);
      neighboursConnDetails.add(neighbourConnectionDetails);
    }
  }
  return neighboursConnDetails;
}

Fixed version (ground truth):
private List<ConnectionDetails> createNeighbourConnectionDetails(ConnectionDetails connectionDetails,List<DeviceNeighbour> neighbours){
  List<ConnectionDetails> neighboursConnDetails=new ArrayList<ConnectionDetails>();
  for (  DeviceNeighbour neighbour : neighbours) {
    connectionDetails.put("String_Node_Str",neighbour.getDeviceType());
    if (neighbour.getStatus()) {
      connectionDetails.put("String_Node_Str",neighbour.getHostName());
      connectionDetails.put("String_Node_Str",neighbour.getIpAddress().getIpAddress());
      connectionDetails.put("String_Node_Str",neighbour.getIpAddress().getNetMask());
      connectionDetails.put("String_Node_Str","String_Node_Str" + neighbour.getROCommunity());
      ConnectionDetails neighbourConnectionDetails=new ConnectionDetails();
      neighbourConnectionDetails.setConnectionType("String_Node_Str");
      neighboursConnDetails.add(neighbourConnectionDetails);
    }
  }
  return neighboursConnDetails;
}
Program: 13103
Project: 13103
Buggy source:
private List<ConnectionDetails> createNeigbourConnectionDetails(ConnectionDetails connectionDetails,Map<String,String> params,List<DeviceNeighbour> neighbours){
  List<ConnectionDetails> neighboursConnDetails=new ArrayList<ConnectionDetails>();
  for (  DeviceNeighbour neighbour : neighbours) {
    params.put("String_Node_Str",neighbour.getDeviceType());
    params.put("String_Node_Str",neighbour.getHostName());
    params.put("String_Node_Str","String_Node_Str" + neighbour.getIpAddress());
    params.put("String_Node_Str","String_Node_Str" + neighbour.getROCommunity());
    ConnectionDetails neighbourConnectionDetails=new ConnectionDetails();
    connectionDetails.setConnectionType("String_Node_Str");
    connectionDetails.setParams(params);
    neighboursConnDetails.add(neighbourConnectionDetails);
  }
  return neighboursConnDetails;
}

Fixed version (ground truth):
private List<ConnectionDetails> createNeigbourConnectionDetails(ConnectionDetails connectionDetails,Map<String,String> params,List<DeviceNeighbour> neighbours){
  List<ConnectionDetails> neighboursConnDetails=new ArrayList<ConnectionDetails>();
  for (  DeviceNeighbour neighbour : neighbours) {
    params.put("String_Node_Str",neighbour.getDeviceType());
    params.put("String_Node_Str",neighbour.getHostName());
    params.put("String_Node_Str","String_Node_Str" + neighbour.getIpAddress());
    params.put("String_Node_Str","String_Node_Str" + neighbour.getROCommunity());
    ConnectionDetails neighbourConnectionDetails=new ConnectionDetails();
    neighbourConnectionDetails.setConnectionType("String_Node_Str");
    neighbourConnectionDetails.setParams(params);
    neighboursConnDetails.add(neighbourConnectionDetails);
  }
  return neighboursConnDetails;
}
Program: 13104
Project: 13104
Buggy source:
private List<ConnectionDetails> createNeigbourConnectionDetails(ConnectionDetails connectionDetails,Map<String,String> params,List<DeviceNeighbour> neighbours){
  List<ConnectionDetails> neighboursConnDetails=new ArrayList<ConnectionDetails>();
  for (  DeviceNeighbour neighbour : neighbours) {
    params.put("String_Node_Str",neighbour.getDeviceType());
    params.put("String_Node_Str",neighbour.getHostName());
    params.put("String_Node_Str","String_Node_Str" + neighbour.getIpAddress());
    params.put("String_Node_Str","String_Node_Str" + neighbour.getROCommunity());
    ConnectionDetails neighbourConnectionDetails=new ConnectionDetails();
    neighbourConnectionDetails.setConnectionType("String_Node_Str");
    neighbourConnectionDetails.setParams(params);
    neighboursConnDetails.add(neighbourConnectionDetails);
  }
  return neighboursConnDetails;
}

Fixed version (ground truth):
private List<ConnectionDetails> createNeigbourConnectionDetails(ConnectionDetails connectionDetails,Map<String,String> params,List<DeviceNeighbour> neighbours){
  List<ConnectionDetails> neighboursConnDetails=new ArrayList<ConnectionDetails>();
  for (  DeviceNeighbour neighbour : neighbours) {
    params.put("String_Node_Str",neighbour.getDeviceType());
    if (neighbour.getStatus()) {
      params.put("String_Node_Str",neighbour.getHostName());
      params.put("String_Node_Str","String_Node_Str" + neighbour.getIpAddress());
      params.put("String_Node_Str","String_Node_Str" + neighbour.getROCommunity());
      ConnectionDetails neighbourConnectionDetails=new ConnectionDetails();
      neighbourConnectionDetails.setConnectionType("String_Node_Str");
      neighbourConnectionDetails.setParams(params);
      neighboursConnDetails.add(neighbourConnectionDetails);
    }
  }
  return neighboursConnDetails;
}
Program: 13105
Project: 13105
Buggy source:
@GET @Produces(MediaType.APPLICATION_XML + "String_Node_Str") @Path("String_Node_Str") public String getNodeAsXml(@PathParam("String_Node_Str") String nodeId) throws IOException, SAXException, ParserConfigurationException {
  if (graph == null) {
    File graphmlFile=new File(context.getInitParameter("String_Node_Str"));
    this.init(DirectedSparseGraph.<String,String>getFactory(),graphmlFile);
  }
  StringBuilder sb=new StringBuilder();
  sb.append(String.format("String_Node_Str",nodeId));
  for (  Object mdKey : gmlr.getVertexMetadata().keySet()) {
    GraphMLMetadata<String> o=(GraphMLMetadata<String>)gmlr.getVertexMetadata().get(mdKey);
    String value=o.transformer.transform((String)nodeId);
    if (value != null) {
      sb.append(String.format("String_Node_Str",mdKey,value));
    }
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
public String getNodeAsXml(@PathParam("String_Node_Str") String nodeId) throws IOException, SAXException, ParserConfigurationException {
  if (graph == null) {
    File graphmlFile=new File(context.getInitParameter("String_Node_Str"));
    this.init(DirectedSparseGraph.<String,String>getFactory(),graphmlFile);
  }
  StringBuilder sb=new StringBuilder();
  sb.append(String.format("String_Node_Str",nodeId));
  for (  Object mdKey : gmlr.getVertexMetadata().keySet()) {
    GraphMLMetadata<String> o=(GraphMLMetadata<String>)gmlr.getVertexMetadata().get(mdKey);
    String value=o.transformer.transform((String)nodeId);
    if (value != null) {
      sb.append(String.format("String_Node_Str",mdKey,value));
    }
  }
  sb.append("String_Node_Str");
  return sb.toString();
}
Program: 13106
Project: 13106
Buggy source:
@GET @Produces({MediaType.APPLICATION_XML + "String_Node_Str",MediaType.TEXT_HTML + "String_Node_Str"}) @Path("String_Node_Str") public String getNodesAsXml() throws IOException, SAXException, ParserConfigurationException {
  if (graph == null) {
    File graphmlFile=new File(context.getInitParameter("String_Node_Str"));
    this.init(DirectedSparseGraph.<String,String>getFactory(),graphmlFile);
  }
  StringBuilder sb=new StringBuilder();
  sb.append(String.format("String_Node_Str",graph.getVertices().size()));
  for (  String vertex : graph.getVertices()) {
    sb.append(String.format("String_Node_Str",vertex));
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@GET @Produces({MediaType.APPLICATION_XML + "String_Node_Str"}) @Path("String_Node_Str") public String getNodesAsXml() throws IOException, SAXException, ParserConfigurationException {
  if (graph == null) {
    File graphmlFile=new File(context.getInitParameter("String_Node_Str"));
    this.init(DirectedSparseGraph.<String,String>getFactory(),graphmlFile);
  }
  StringBuilder sb=new StringBuilder();
  sb.append(String.format("String_Node_Str",graph.getVertices().size()));
  for (  String vertex : graph.getVertices()) {
    sb.append(String.format("String_Node_Str",vertex));
  }
  sb.append("String_Node_Str");
  return sb.toString();
}
Program: 13107
Project: 13107
Buggy source:
@GET @Produces("String_Node_Str") @Path("String_Node_Str") public String getNodeAsHtmlById(@QueryParam("String_Node_Str") String nodeId) throws IOException, SAXException, ParserConfigurationException {
  if (graph == null) {
    File graphmlFile=new File(context.getInitParameter("String_Node_Str"));
    this.init(DirectedSparseGraph.<String,String>getFactory(),graphmlFile);
  }
  if (nodeId == null) {
    return getNodesAsHtml();
  }
  StringBuilder sb=new StringBuilder();
  sb.append(String.format("String_Node_Str",nodeId));
  for (  Object mdKey : gmlr.getVertexMetadata().keySet()) {
    GraphMLMetadata<String> o=(GraphMLMetadata<String>)gmlr.getVertexMetadata().get(mdKey);
    String value=o.transformer.transform((String)nodeId);
    if (value != null) {
      sb.append(String.format("String_Node_Str",mdKey,value));
    }
  }
  sb.append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@GET @Produces(MediaType.TEXT_HTML + "String_Node_Str") @Path("String_Node_Str") public String getNodeAsHtmlById(@QueryParam("String_Node_Str") String nodeId) throws IOException, SAXException, ParserConfigurationException {
  if (graph == null) {
    File graphmlFile=new File(context.getInitParameter("String_Node_Str"));
    this.init(DirectedSparseGraph.<String,String>getFactory(),graphmlFile);
  }
  if (nodeId == null) {
    return getNodesAsHtml();
  }
  StringBuilder sb=new StringBuilder();
  sb.append(String.format("String_Node_Str",nodeId));
  for (  Object mdKey : gmlr.getVertexMetadata().keySet()) {
    GraphMLMetadata<String> o=(GraphMLMetadata<String>)gmlr.getVertexMetadata().get(mdKey);
    String value=o.transformer.transform((String)nodeId);
    if (value != null) {
      sb.append(String.format("String_Node_Str",mdKey,value));
    }
  }
  sb.append("String_Node_Str");
  return sb.toString();
}
Program: 13109
Project: 13109
Buggy source:
@Override public String toString(){
  final StringBuilder sb=new StringBuilder();
  sb.append(DateFormat.format(DATE_FORMAT,new Date(time))).append("String_Node_Str");
  sb.append(level.toString()).append("String_Node_Str");
  sb.append(tag).append("String_Node_Str");
  sb.append(message).append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  final SimpleDateFormat formatter=new SimpleDateFormat(DATE_FORMAT);
  final StringBuilder sb=new StringBuilder();
  sb.append(formatter.format(new Date(time))).append("String_Node_Str");
  sb.append(level.toString()).append("String_Node_Str");
  sb.append(tag).append("String_Node_Str");
  sb.append(message).append("String_Node_Str");
  return sb.toString();
}
Program: 13110
Project: 13110
Buggy source:
@Override public String toString(){
  final StringBuilder sb=new StringBuilder();
  sb.append(DATE_FORMAT.format(new Date(time))).append("String_Node_Str");
  sb.append(level.toString()).append("String_Node_Str");
  sb.append(tag).append("String_Node_Str");
  sb.append(message).append("String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  final StringBuilder sb=new StringBuilder();
  sb.append(DateFormat.format(DATE_FORMAT,new Date(time))).append("String_Node_Str");
  sb.append(level.toString()).append("String_Node_Str");
  sb.append(tag).append("String_Node_Str");
  sb.append(message).append("String_Node_Str");
  return sb.toString();
}
Program: 13111
Project: 13111
Buggy source:
public static void printlnLogOnScreen(final LogEvent event){
  if (appContext == null) {
    return;
  }
  final Collection<WeakReference<TextView>> weakTextViews=repository.getTextViews();
  if (weakTextViews.isEmpty()) {
    return;
  }
  final String logText=event.toString();
  final int logTextLength=logText.length();
  final Handler mainHandler=new Handler(appContext.getMainLooper());
  for (  final WeakReference<TextView> weakTextView : weakTextViews) {
    final TextView textView=weakTextView.get();
    if (textView == null) {
      continue;
    }
    final String viewText=textView.getText().toString();
    int viewTextLength=viewText.length();
    final StringBuilder sb=new StringBuilder(viewText);
    while (viewTextLength + logTextLength > MAX_LOG_TEXT_LENGHT_IN_VIEW) {
      final int index=sb.indexOf("String_Node_Str");
      sb.delete(0,index);
      viewTextLength=sb.length();
    }
    sb.append(logText);
    final String newViewText=sb.toString();
    mainHandler.post(new Runnable(){
      @Override public void run(){
        final TextView textView=weakTextView.get();
        if (textView != null) {
          textView.setText(newViewText);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
public static void printlnLogOnScreen(final LogEvent event){
  if (appContext == null || event == null) {
    return;
  }
  final Collection<WeakReference<TextView>> weakTextViews=repository.getTextViews();
  if (weakTextViews.isEmpty()) {
    return;
  }
  final String logText=event.toString();
  final int logTextLength=logText.length();
  final Handler mainHandler=new Handler(appContext.getMainLooper());
  for (  final WeakReference<TextView> weakTextView : weakTextViews) {
    final TextView textView=weakTextView.get();
    if (textView == null) {
      continue;
    }
    final String viewText=textView.getText().toString();
    int viewTextLength=viewText.length();
    final StringBuilder sb=new StringBuilder(viewText);
    while (viewTextLength + logTextLength > MAX_LOG_TEXT_LENGHT_IN_VIEW) {
      final int index=sb.indexOf("String_Node_Str");
      sb.delete(0,index);
      viewTextLength=sb.length();
    }
    sb.append(logText);
    final String newViewText=sb.toString();
    mainHandler.post(new Runnable(){
      @Override public void run(){
        final TextView textView=weakTextView.get();
        if (textView != null) {
          textView.setText(newViewText);
        }
      }
    }
);
  }
}
Program: 13112
Project: 13112
Buggy source:
private static InputStream readConfiguresFromClasspath(){
  tryToloadPropertiesFromClasspath=true;
  final String filename=CONFIG_FILE_NAME + "String_Node_Str";
  InputStream in=null;
  try {
    in=LoggerFactory.class.getClassLoader().getResourceAsStream(filename);
  }
 catch (  final Exception e) {
  }
  if (in == null) {
    try {
      in=ClassLoader.getSystemClassLoader().getResourceAsStream(filename);
    }
 catch (    final Exception e) {
    }
  }
  if (in != null) {
    internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
  }
  return in;
}

Fixed version (ground truth):
private static InputStream readConfiguresFromClasspath(){
  tryToloadPropertiesFromClasspath=true;
  final String filename=CONFIG_FILE_NAME + "String_Node_Str";
  LoggerFactory.class.getClassLoader();
  InputStream in=LoggerFactory.class.getClassLoader().getResourceAsStream("String_Node_Str" + filename);
  if (in != null) {
    internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
  }
 else {
    in=LoggerFactory.class.getClassLoader().getResourceAsStream("String_Node_Str" + filename);
    if (in != null) {
      internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
    }
  }
  return in;
}
Program: 13113
Project: 13113
Buggy source:
/** 
 * Get the logger of the calling class.
 * @return logger of the calling class
 * @since 0.1.0-RELEASE
 */
public static Logger getLogger(){
synchronized (LoggerFactory.class) {
    if (!loadPropertiesSuccess && !tryToloadPropertiesFromClasspath) {
      final Properties configProperties=loadProperties(readConfiguresFromClasspath());
      if (configProperties != null) {
        parseProperties(configProperties);
      }
    }
    final String caller=getCallerClassName();
    internalLogger.verbose("String_Node_Str",caller);
    final Logger logger=getDeclaredLogger(caller);
    return logger != null ? logger : getNewLogger(caller);
  }
}

Fixed version (ground truth):
/** 
 * Get the logger of the calling class.
 * @return logger of the calling class
 * @since 0.1.0-RELEASE
 */
public static Logger getLogger(){
synchronized (LoggerFactory.class) {
    if (!loadPropertiesSuccess && !tryToloadPropertiesFromClasspath) {
      checkEnvironmentAndSetup(DEFAULT_RELEASE_LOG_LEVEL);
      final Properties configProperties=loadProperties(readConfiguresFromClasspath());
      if (configProperties != null) {
        parseProperties(configProperties);
      }
    }
    final String caller=getCallerClassName();
    internalLogger.verbose("String_Node_Str",caller);
    final Logger logger=getDeclaredLogger(caller);
    return logger != null ? logger : getNewLogger(caller);
  }
}
Program: 13114
Project: 13114
Buggy source:
/** 
 * Locate the config properties file, search assets folder, res/raw in order, read the file after found.
 * @return the properties of config file, if file not found return{@code null}
 */
private static Properties locateAndLoadProperties(){
  InputStream in=null;
  final String filename=CONFIG_FILE_NAME + "String_Node_Str";
  try {
    in=appContext.getAssets().open(filename);
    internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
  }
 catch (  final IOException e) {
  }
  if (in == null) {
    final String packageName=appContext.getPackageName();
    try {
      final int id=Utils.intReflectStaticFieldValue(packageName + "String_Node_Str",CONFIG_FILE_NAME,-1);
      if (id != -1) {
        in=appContext.getResources().openRawResource(id);
        internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
      }
    }
 catch (    final Exception e) {
    }
  }
  if (in == null) {
    in=readConfiguresFromClasspath();
  }
  return loadProperties(in);
}

Fixed version (ground truth):
/** 
 * Locate the config properties file, search assets folder, res/raw in order, read the file after found.
 * @return the properties of config file, if file not found return{@code null}
 */
private static Properties locateAndLoadProperties(){
  InputStream in=null;
  final String filename=CONFIG_FILE_NAME + "String_Node_Str";
  try {
    in=appContext.getAssets().open(filename);
    internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
  }
 catch (  final IOException e) {
  }
  if (in == null) {
    final String packageName=appContext.getPackageName();
    try {
      final int id=Utils.intReflectStaticFieldValue(packageName + "String_Node_Str",CONFIG_FILE_NAME,-1);
      if (id != -1) {
        in=appContext.getResources().openRawResource(id);
        internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
      }
    }
 catch (    final Exception e) {
    }
  }
  return loadProperties(in);
}
Program: 13115
Project: 13115
Buggy source:
/** 
 * Read the value of 'package.BuildConfig.DEBUG', this value is   {@code true}in developing and is   {@code false} after being packaged(release mode). Ingenerally, we want to hide the low level log message in release mode.
 * @param level log level of the root logger in release mode
 */
private static void checkEnvironmentAndSetup(final LogLevel level){
  final String packageName=appContext.getPackageName();
  final boolean underDevelopment=Utils.booleanReflectStaticFieldValue(packageName + "String_Node_Str","String_Node_Str",true);
  if (!underDevelopment) {
    ConfigureRepository.setInternalLogLevel(LogLevel.OFF);
    repository.setRootLoggerConfig(new LoggerConfig("String_Node_Str",null,level,false));
  }
}

Fixed version (ground truth):
/** 
 * Read the value of 'package.BuildConfig.DEBUG', this value is   {@code true}in developing and is   {@code false} after being packaged(release mode). Ingenerally, we want to hide the low level log message in release mode.
 * @param level log level of the root logger in release mode
 */
private static void checkEnvironmentAndSetup(final LogLevel level){
  String packageName;
  if (appContext != null) {
    packageName=appContext.getPackageName();
  }
 else {
    packageName=getPackageNameFromAndroidManifest();
  }
  final boolean underDevelopment=Utils.booleanReflectStaticFieldValue(packageName + "String_Node_Str","String_Node_Str",true);
  if (!underDevelopment) {
    ConfigureRepository.setInternalLogLevel(LogLevel.OFF);
    repository.setRootLoggerConfig(new LoggerConfig("String_Node_Str",null,level,false));
  }
}
Program: 13116
Project: 13116
Buggy source:
private static Properties loadProperties(final InputStream in){
  if (in == null) {
    return null;
  }
  final Properties properties=new Properties();
  try {
    properties.load(in);
  }
 catch (  final IOException e) {
    return null;
  }
 finally {
    try {
      in.close();
    }
 catch (    final IOException e) {
    }
  }
  return properties;
}

Fixed version (ground truth):
private static Properties loadProperties(final InputStream in){
  if (in == null) {
    internalLogger.verbose("String_Node_Str",CONFIG_FILE_NAME);
    return null;
  }
  final Properties properties=new Properties();
  try {
    properties.load(in);
  }
 catch (  final IOException e) {
    return null;
  }
 finally {
    try {
      in.close();
    }
 catch (    final IOException e) {
    }
  }
  return properties;
}
Program: 13117
Project: 13117
Buggy source:
public void start(){
  if (isStarted() || isStop()) {
    throw new IllegalStateException("String_Node_Str");
  }
  try {
    createAndOpenLogFile();
    worker.start();
  }
 catch (  final Exception e) {
    stop();
    internalLogger.verbose(e,"String_Node_Str");
  }
  started=true;
}

Fixed version (ground truth):
public void start(){
  if (isStarted() || isStop()) {
    throw new IllegalStateException("String_Node_Str");
  }
  try {
    createAndOpenLogFile();
    worker.start();
    started=true;
  }
 catch (  final Exception e) {
    stop();
    internalLogger.verbose(e,"String_Node_Str");
  }
}
Program: 13118
Project: 13118
Buggy source:
/** 
 * Internal method that prints log message.
 * @param level the LogLevel of the log message
 * @param t a throwable(exception) object, can be  {@code null}
 * @param format a format string of the log message, can be  {@code null}.
 * @param args an array of arguments, can be  {@code null}
 * @since 0.1.0-RELEASE
 */
protected void println(final LogLevel level,final Throwable t,final String format,final Object... args){
  if (this.level.includes(level) && (t != null || format != null)) {
    String message=null;
    if (format != null && format.length() > 0) {
      message=(args != null && args.length > 0) ? String.format(format,args) : format;
    }
    if (t != null) {
      message=message != null ? message + "String_Node_Str" + Log.getStackTraceString(t) : Log.getStackTraceString(t);
    }
    if (thread) {
      Log.println(level.intValue(),"String_Node_Str" + Thread.currentThread().getName() + "String_Node_Str",message);
    }
 else {
      Log.println(level.intValue(),tag,message);
    }
  }
}

Fixed version (ground truth):
/** 
 * Internal method that prints log message.
 * @param level the LogLevel of the log message
 * @param t a throwable(exception) object, can be  {@code null}
 * @param format a format string of the log message, can be  {@code null}.
 * @param args an array of arguments, can be  {@code null}
 * @since 0.1.0-RELEASE
 */
protected void println(final LogLevel level,final Throwable t,final String format,final Object... args){
  if (this.level.includes(level) && (t != null || format != null)) {
    String message=null;
    if (format != null && format.length() > 0) {
      message=(args != null && args.length > 0) ? String.format(format,args) : format;
    }
    if (t != null) {
      message=message != null ? message + "String_Node_Str" + Log.getStackTraceString(t) : Log.getStackTraceString(t);
    }
    if (thread) {
      final StringBuilder sb=new StringBuilder();
      sb.append("String_Node_Str").append(Thread.currentThread().getName()).append("String_Node_Str").append(tag);
      Log.println(level.intValue(),sb.toString(),message);
    }
 else {
      Log.println(level.intValue(),tag,message);
    }
  }
}
Program: 13119
Project: 13119
Buggy source:
/** 
 * Internal method that prints log message.
 * @param level the LogLevel of the log message
 * @param t a throwable(exception) object, can be  {@code null}
 * @param format a format string of the log message, can be  {@code null}.
 * @param args an array of arguments, can be  {@code null}
 */
protected void println(final LogLevel level,final Throwable t,final String format,final Object... args){
  if (this.level.includes(level) && (t != null || format != null)) {
    String message=null;
    if (format != null && format.length() > 0) {
      message=(args != null && args.length > 0) ? String.format(format,args) : format;
    }
    if (t != null) {
      message=message != null ? message + Log.getStackTraceString(t) : Log.getStackTraceString(t);
    }
    Log.println(level.intValue(),tag,message);
  }
}

Fixed version (ground truth):
/** 
 * Internal method that prints log message.
 * @param level the LogLevel of the log message
 * @param t a throwable(exception) object, can be  {@code null}
 * @param format a format string of the log message, can be  {@code null}.
 * @param args an array of arguments, can be  {@code null}
 */
protected void println(final LogLevel level,final Throwable t,final String format,final Object... args){
  if (this.level.includes(level) && (t != null || format != null)) {
    String message=null;
    if (format != null && format.length() > 0) {
      message=(args != null && args.length > 0) ? String.format(format,args) : format;
    }
    if (t != null) {
      message=message != null ? message + "String_Node_Str" + Log.getStackTraceString(t) : Log.getStackTraceString(t);
    }
    Log.println(level.intValue(),tag,message);
  }
}
Program: 13120
Project: 13120
Buggy source:
@Test public void test() throws IOException, JBIG2Exception, NoSuchAlgorithmException {
  final URL imageUrl=JBIG2ImageReaderDemo.class.getResource(resourcePath);
  final InputStream inputStream=new FileInputStream(new File(imageUrl.getPath()));
  final InputStreamFactory disf=new DefaultInputStreamFactory();
  final ImageInputStream iis=disf.getInputStream(inputStream);
  final JBIG2DocumentFacade doc=new JBIG2DocumentFacade(iis);
  final Bitmap b=doc.getPageBitmap(pageNumber);
  final WritableRaster raster=Bitmaps.asRaster(b,param,filterType);
  final DataBufferByte dataBufferByte=(DataBufferByte)raster.getDataBuffer();
  final byte[] bytes=dataBufferByte.getData();
  final MessageDigest md=MessageDigest.getInstance("String_Node_Str");
  final byte[] digest=md.digest(bytes);
  final StringBuilder sb=new StringBuilder();
  for (  byte toAppend : digest) {
    sb.append(toAppend);
  }
  assertArrayEquals(checksum.getBytes(),sb.toString().getBytes());
}

Fixed version (ground truth):
@Test public void test() throws IOException, JBIG2Exception, NoSuchAlgorithmException {
  final InputStream inputStream=JBIG2ImageReaderDemo.class.getResourceAsStream(resourcePath);
  final InputStreamFactory disf=new DefaultInputStreamFactory();
  final ImageInputStream iis=disf.getInputStream(inputStream);
  final JBIG2DocumentFacade doc=new JBIG2DocumentFacade(iis);
  final Bitmap b=doc.getPageBitmap(pageNumber);
  final WritableRaster raster=Bitmaps.asRaster(b,param,filterType);
  final DataBufferByte dataBufferByte=(DataBufferByte)raster.getDataBuffer();
  final byte[] bytes=dataBufferByte.getData();
  final MessageDigest md=MessageDigest.getInstance("String_Node_Str");
  final byte[] digest=md.digest(bytes);
  final StringBuilder sb=new StringBuilder();
  for (  byte toAppend : digest) {
    sb.append(toAppend);
  }
  assertArrayEquals(checksum.getBytes(),sb.toString().getBytes());
}
Program: 13121
Project: 13121
Buggy source:
private void preprocessCodes(List<Code> codeTable){
  int maxPrefixLength=0;
  for (  Code c : codeTable) {
    maxPrefixLength=Math.max(maxPrefixLength,c.prefixLength);
  }
  int lenCount[]=new int[maxPrefixLength + 1];
  for (  Code c : codeTable) {
    lenCount[c.prefixLength]++;
  }
  int curCode, curTemp;
  int firstCode[]=new int[lenCount.length + 1];
  lenCount[0]=0;
  for (int curLen=1; curLen <= lenCount.length; curLen++) {
    firstCode[curLen]=(firstCode[curLen - 1] + (lenCount[curLen - 1]) << 1);
    curCode=firstCode[curLen];
    for (    Code code : codeTable) {
      if (code.prefixLength == curLen) {
        code.code=curCode;
        curCode++;
      }
    }
  }
  if (JBIG2ImageReader.DEBUG)   System.out.println(codeTableToString(codeTable));
}

Fixed version (ground truth):
private void preprocessCodes(List<Code> codeTable){
  int maxPrefixLength=0;
  for (  Code c : codeTable) {
    maxPrefixLength=Math.max(maxPrefixLength,c.prefixLength);
  }
  int lenCount[]=new int[maxPrefixLength + 1];
  for (  Code c : codeTable) {
    lenCount[c.prefixLength]++;
  }
  int curCode;
  int firstCode[]=new int[lenCount.length + 1];
  lenCount[0]=0;
  for (int curLen=1; curLen <= lenCount.length; curLen++) {
    firstCode[curLen]=(firstCode[curLen - 1] + (lenCount[curLen - 1]) << 1);
    curCode=firstCode[curLen];
    for (    Code code : codeTable) {
      if (code.prefixLength == curLen) {
        code.code=curCode;
        curCode++;
      }
    }
  }
  if (JBIG2ImageReader.DEBUG)   System.out.println(codeTableToString(codeTable));
}
Program: 13122
Project: 13122
Buggy source:
public void initTree(List<Code> codeTable){
  preprocessCodes(codeTable);
  for (  Code c : codeTable) {
    rootNode.append(c);
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public void initTree(List<Code> codeTable){
  preprocessCodes(codeTable);
  for (  Code c : codeTable) {
    rootNode.append(c);
  }
}
Program: 13123
Project: 13123
Buggy source:
private void preprocessCodes(List<Code> codeTable){
  int maxPrefixLength=0;
  for (  Code c : codeTable) {
    maxPrefixLength=Math.max(maxPrefixLength,c.prefixLength);
  }
  int lenCount[]=new int[maxPrefixLength + 1];
  for (  Code c : codeTable) {
    lenCount[c.prefixLength]++;
  }
  int curCode, curTemp;
  int firstCode[]=new int[lenCount.length + 1];
  lenCount[0]=0;
  for (int curLen=1; curLen <= lenCount.length; curLen++) {
    firstCode[curLen]=(firstCode[curLen - 1] + (lenCount[curLen - 1]) << 1);
    curCode=firstCode[curLen];
    for (    Code code : codeTable) {
      if (code.prefixLength == curLen) {
        code.code=curCode;
        curCode++;
      }
    }
  }
  if (JBIG2ImageReader.DEBUG)   System.out.println(codeTableToString(codeTable));
}

Fixed version (ground truth):
private void preprocessCodes(List<Code> codeTable){
  int maxPrefixLength=0;
  for (  Code c : codeTable) {
    maxPrefixLength=Math.max(maxPrefixLength,c.prefixLength);
  }
  int lenCount[]=new int[maxPrefixLength + 1];
  for (  Code c : codeTable) {
    lenCount[c.prefixLength]++;
  }
  int curCode;
  int firstCode[]=new int[lenCount.length + 1];
  lenCount[0]=0;
  for (int curLen=1; curLen <= lenCount.length; curLen++) {
    firstCode[curLen]=(firstCode[curLen - 1] + (lenCount[curLen - 1]) << 1);
    curCode=firstCode[curLen];
    for (    Code code : codeTable) {
      if (code.prefixLength == curLen) {
        code.code=curCode;
        curCode++;
      }
    }
  }
  if (JBIG2ImageReader.DEBUG)   System.out.println(codeTableToString(codeTable));
}
Program: 13124
Project: 13124
Buggy source:
public void initTree(List<Code> codeTable){
  preprocessCodes(codeTable);
  for (  Code c : codeTable) {
    rootNode.append(c);
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public void initTree(List<Code> codeTable){
  preprocessCodes(codeTable);
  for (  Code c : codeTable) {
    rootNode.append(c);
  }
}
Program: 13125
Project: 13125
Buggy source:
/** 
 * <a href="https://github.com/levigo/jbig2-imageio/issues/21">Github issue 21s</a>
 */
@Test public void issue21() throws Exception {
  final byte[] md5Expected=new byte[]{-79,69,103,64,59,120,-74,117,-96,-86,-23,36,-122,113,101,-99};
  final InputStream imageStream=getClass().getResourceAsStream("String_Node_Str");
  final InputStream globalsStream=getClass().getResourceAsStream("String_Node_Str");
  final ImageInputStream globalsIIS=ImageIO.createImageInputStream(globalsStream);
  final ImageInputStream imageIIS=ImageIO.createImageInputStream(imageStream);
  byte[] md5Actual=null;
  try {
    final JBIG2Document doc=doc(imageIIS,globalsIIS);
    final JBIG2Page page=doc.getPage(1);
    final Bitmap bitmap=page.getBitmap();
    md5Actual=md5(bitmap);
  }
  finally {
    Assert.assertArrayEquals(md5Expected,md5Actual);
    globalsIIS.close();
    globalsStream.close();
    imageIIS.close();
    imageStream.close();
  }
}

Fixed version (ground truth):
/** 
 * <a href="https://github.com/levigo/jbig2-imageio/issues/21">Github issue 21s</a>
 */
@Test public void issue21() throws Exception {
  final byte[] md5Expected=new byte[]{83,74,-69,-60,-122,-99,21,126,-115,13,9,107,-31,-109,77,-119};
  final InputStream imageStream=getClass().getResourceAsStream("String_Node_Str");
  final InputStream globalsStream=getClass().getResourceAsStream("String_Node_Str");
  final ImageInputStream globalsIIS=ImageIO.createImageInputStream(globalsStream);
  final ImageInputStream imageIIS=ImageIO.createImageInputStream(imageStream);
  byte[] md5Actual=null;
  try {
    final JBIG2Document doc=doc(imageIIS,globalsIIS);
    final JBIG2Page page=doc.getPage(1);
    final Bitmap bitmap=page.getBitmap();
    md5Actual=md5(bitmap);
  }
  finally {
    Assert.assertArrayEquals(md5Expected,md5Actual);
    globalsIIS.close();
    globalsStream.close();
    imageIIS.close();
    imageStream.close();
  }
}