Program: 80827
Project: 80827
Buggy source:
@Override public void handleGET(CoapExchange exchange){
  Collection<Resource> resources=rdResource.getChildren();
  String result="String_Node_Str";
  String domainQuery="String_Node_Str";
  String endpointQuery="String_Node_Str";
  List<String> toRemove=new ArrayList<String>();
  List<String> query=exchange.getRequestOptions().getUriQuery();
  for (  String q : query) {
    LinkAttribute attr=LinkAttribute.parse(q);
    if (attr.getName().equals(LinkFormat.DOMAIN)) {
      domainQuery=attr.getValue();
      if (domainQuery == null) {
        exchange.respond(ResponseCode.BAD_REQUEST);
        return;
      }
      toRemove.add(q);
    }
    if (attr.getName().equals(LinkFormat.END_POINT)) {
      endpointQuery=attr.getValue();
      if (endpointQuery == null) {
        exchange.respond(ResponseCode.BAD_REQUEST);
        return;
      }
      toRemove.add(q);
    }
  }
  Iterator<Resource> resIt=resources.iterator();
  query.removeAll(toRemove);
  while (resIt.hasNext()) {
    Resource res=resIt.next();
    if (res instanceof RDNodeResource) {
      RDNodeResource node=(RDNodeResource)res;
      if ((domainQuery.isEmpty() || domainQuery.equals(node.getDomain())) && (endpointQuery.isEmpty() || endpointQuery.equals(node.getEndpointIdentifier()))) {
        String link=node.toLinkFormat(query);
        result+=(!link.isEmpty()) ? link + "String_Node_Str" : "String_Node_Str";
      }
    }
  }
  if (result.isEmpty()) {
    exchange.respond(ResponseCode.NOT_FOUND);
  }
 else {
    exchange.respond(ResponseCode.CONTENT,result.substring(0,result.length() - 1),MediaTypeRegistry.APPLICATION_LINK_FORMAT);
  }
}

Fixed version (ground truth):
@Override public void handleGET(CoapExchange exchange){
  Collection<Resource> resources=rdResource.getChildren();
  String result="String_Node_Str";
  String domainQuery="String_Node_Str";
  String endpointQuery="String_Node_Str";
  List<String> toRemove=new ArrayList<String>();
  List<String> query=exchange.getRequestOptions().getUriQuery();
  for (  String q : query) {
    KeyValuePair kvp=KeyValuePair.parse(q);
    if (LinkFormat.DOMAIN.equals(kvp.getName())) {
      if (kvp.isFlag()) {
        exchange.respond(ResponseCode.BAD_REQUEST,"String_Node_Str");
        return;
      }
 else {
        domainQuery=kvp.getValue();
        toRemove.add(q);
      }
    }
    if (LinkFormat.END_POINT.equals(kvp.getName())) {
      if (kvp.isFlag()) {
        exchange.respond(ResponseCode.BAD_REQUEST,"String_Node_Str");
        return;
      }
 else {
        endpointQuery=kvp.getValue();
        toRemove.add(q);
      }
    }
  }
  query.removeAll(toRemove);
  Iterator<Resource> resIt=resources.iterator();
  while (resIt.hasNext()) {
    Resource res=resIt.next();
    if (res instanceof RDNodeResource) {
      RDNodeResource node=(RDNodeResource)res;
      if ((domainQuery.isEmpty() || domainQuery.equals(node.getDomain())) && (endpointQuery.isEmpty() || endpointQuery.equals(node.getEndpointName()))) {
        String link=node.toLinkFormat(query);
        result+=(!link.isEmpty()) ? link + "String_Node_Str" : "String_Node_Str";
      }
    }
  }
  if (result.isEmpty()) {
    exchange.respond(ResponseCode.NOT_FOUND);
  }
 else {
    exchange.respond(ResponseCode.CONTENT,result.substring(0,result.length() - 1),MediaTypeRegistry.APPLICATION_LINK_FORMAT);
  }
}