Program: 83966
Project: 83966
Buggy source:
/** 
 * Resolves the uri.  If query has been posted, it is applied to each resource that the uri solves to.  The results are returns in the following format. { "/is4/...":{..} } The attribute is the uri, the value is the results of applying the query to that uri.
 */
protected void handleRecursiveFSQuery(HttpExchange exchange,boolean internalCall,JSONObject internalResp){
  String requestUri=exchangeJSON.getString("String_Node_Str");
  exchange.setAttribute("String_Node_Str","String_Node_Str");
  logger.info("String_Node_Str" + requestUri + "String_Node_Str"+ internalCall);
  JSONArray resolvedUris=new JSONArray();
  String uriOnly=requestUri;
  if (requestUri.contains("String_Node_Str")) {
    uriOnly=requestUri.substring(0,uriOnly.indexOf("String_Node_Str"));
    logger.info("String_Node_Str" + uriOnly + "String_Node_Str"+ (String)exchange.getAttribute("String_Node_Str"));
    resolvedUris.addAll(database.resolveStarredUri(uriOnly,(String)exchange.getAttribute("String_Node_Str")));
  }
 else {
    resolvedUris.addAll(database.resolveStarredUri(uriOnly,null));
  }
  logger.info("String_Node_Str" + resolvedUris.toString());
  String requestMethod=exchange.getRequestMethod();
  String putPostData=null;
  if (requestMethod.equalsIgnoreCase("String_Node_Str") || requestMethod.equalsIgnoreCase("String_Node_Str"))   putPostData=getPutPostData(exchange);
  JSONObject responses=new JSONObject();
  try {
    if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.get(exchange,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            processResponse(thisResource,respBuffer);
            responses.putAll(respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
 else     if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.put(exchange,putPostData,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            processResponse(thisResource,respBuffer);
            responses.putAll(respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
 else     if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.post(exchange,putPostData,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            processResponse(thisResource,respBuffer);
            responses.putAll(respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
 else     if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      if (resolvedUris.size() > 0)       depthFirstSort(resolvedUris);
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.delete(exchange,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            processResponse(thisResource,respBuffer);
            responses.putAll(respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    logger.log(Level.WARNING,"String_Node_Str",e);
  }
  sendResponse(exchange,200,responses.toString(),internalCall,internalResp);
}

Fixed version (ground truth):
/** 
 * Resolves the uri.  If query has been posted, it is applied to each resource that the uri solves to.  The results are returns in the following format. { "/is4/...":{..} } The attribute is the uri, the value is the results of applying the query to that uri.
 */
protected void handleRecursiveFSQuery(HttpExchange exchange,boolean internalCall,JSONObject internalResp){
  String requestUri=exchangeJSON.getString("String_Node_Str");
  exchange.setAttribute("String_Node_Str","String_Node_Str");
  logger.info("String_Node_Str" + requestUri + "String_Node_Str"+ internalCall);
  JSONArray resolvedUris=new JSONArray();
  String uriOnly=requestUri;
  if (requestUri.contains("String_Node_Str")) {
    uriOnly=requestUri.substring(0,uriOnly.indexOf("String_Node_Str"));
    logger.info("String_Node_Str" + uriOnly + "String_Node_Str"+ (String)exchange.getAttribute("String_Node_Str"));
    resolvedUris.addAll(database.resolveStarredUri(uriOnly,(String)exchange.getAttribute("String_Node_Str")));
  }
 else {
    resolvedUris.addAll(database.resolveStarredUri(uriOnly,null));
  }
  logger.info("String_Node_Str" + resolvedUris.toString());
  String requestMethod=exchange.getRequestMethod();
  String putPostData=null;
  if (requestMethod.equalsIgnoreCase("String_Node_Str") || requestMethod.equalsIgnoreCase("String_Node_Str"))   putPostData=getPutPostData(exchange);
  JSONObject responses=new JSONObject();
  try {
    if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.get(exchange,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            respBuffer.put("String_Node_Str",database.getSymlinkAlias(thisResource.URI));
            responses.put(thisResource.URI,respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
 else     if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.put(exchange,putPostData,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            respBuffer.put("String_Node_Str",database.getSymlinkAlias(thisResource.URI));
            responses.put(thisResource.URI,respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
 else     if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.post(exchange,putPostData,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            respBuffer.put("String_Node_Str",database.getSymlinkAlias(thisResource.URI));
            responses.put(thisResource.URI,respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
 else     if (requestMethod.equalsIgnoreCase("String_Node_Str")) {
      if (resolvedUris.size() > 0)       depthFirstSort(resolvedUris);
      for (int i=0; i < resolvedUris.size(); i++) {
        Resource thisResource=RESTServer.getResource(resolvedUris.getString(i));
        if (thisResource != null) {
          JSONObject respBuffer=new JSONObject();
          this.exchangeJSON.put("String_Node_Str",resolvedUris.getString(i));
          thisResource.setExchangeJSON(this.exchangeJSON);
          thisResource.delete(exchange,true,respBuffer);
          if (thisResource.TYPE == ResourceUtils.SYMLINK_RSRC) {
            respBuffer.put("String_Node_Str",database.getSymlinkAlias(thisResource.URI));
            responses.put(thisResource.URI,respBuffer);
          }
 else {
            responses.put(thisResource.URI,respBuffer);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    logger.log(Level.WARNING,"String_Node_Str",e);
  }
  sendResponse(exchange,200,responses.toString(),internalCall,internalResp);
}