Program: 188322
Project: 188322
Buggy source:
public static ConsumesOutputStream retrieveClassificationPlan(User user,String filename) throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException {
  try {
    JsonFactory factory=new JsonFactory();
    ObjectMapper mapper=new ObjectMapper(factory);
    ObjectNode root=mapper.createObjectNode();
    ArrayNode array=mapper.createArrayNode();
    List<String> descriptionsLevels=RodaUtils.copyList(RodaCoreFactory.getRodaConfiguration().getList(RodaConstants.LEVELS_CLASSIFICATION_PLAN));
    Filter allButRepresentationsFilter=new Filter(new OneOfManyFilterParameter(RodaConstants.AIP_LEVEL,descriptionsLevels));
    IndexService index=RodaCoreFactory.getIndexService();
    boolean justActive=true;
    boolean removeDuplicates=true;
    IterableIndexResult<IndexedAIP> res=index.findAll(IndexedAIP.class,allButRepresentationsFilter,null,Sublist.ALL,user,justActive,removeDuplicates,new ArrayList<>());
    Iterator<IndexedAIP> it=res.iterator();
    while (it.hasNext()) {
      array.add(aipToJSON(it.next()));
    }
    root.set("String_Node_Str",array);
    return new ConsumesOutputStream(){
      @Override public void consumeOutputStream(      OutputStream out) throws IOException {
        try {
          mapper.writeValue(out,root);
        }
 catch (        IOException e) {
          throw e;
        }
 finally {
          IOUtils.closeQuietly(out);
        }
      }
      @Override public String getFileName(){
        return filename;
      }
      @Override public String getMediaType(){
        return RodaConstants.MEDIA_TYPE_APPLICATION_JSON;
      }
    }
;
  }
 catch (  IOException e) {
    throw new GenericException(e);
  }
}

Fixed version (ground truth):
public static ConsumesOutputStream retrieveClassificationPlan(User user,String filename) throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException {
  try {
    JsonFactory factory=new JsonFactory();
    ObjectMapper mapper=new ObjectMapper(factory);
    ObjectNode root=mapper.createObjectNode();
    ArrayNode array=mapper.createArrayNode();
    List<String> descriptionsLevels=RodaUtils.copyList(RodaCoreFactory.getRodaConfiguration().getList(RodaConstants.LEVELS_CLASSIFICATION_PLAN));
    Filter allButRepresentationsFilter=new Filter(new OneOfManyFilterParameter(RodaConstants.AIP_LEVEL,descriptionsLevels));
    IndexService index=RodaCoreFactory.getIndexService();
    boolean justActive=true;
    IterableIndexResult<IndexedAIP> res=index.findAll(IndexedAIP.class,allButRepresentationsFilter,null,Sublist.ALL,user,justActive,new ArrayList<>());
    Iterator<IndexedAIP> it=res.iterator();
    while (it.hasNext()) {
      array.add(aipToJSON(it.next()));
    }
    root.set("String_Node_Str",array);
    return new ConsumesOutputStream(){
      @Override public void consumeOutputStream(      OutputStream out) throws IOException {
        try {
          mapper.writeValue(out,root);
        }
 catch (        IOException e) {
          throw e;
        }
 finally {
          IOUtils.closeQuietly(out);
        }
      }
      @Override public String getFileName(){
        return filename;
      }
      @Override public String getMediaType(){
        return RodaConstants.MEDIA_TYPE_APPLICATION_JSON;
      }
    }
;
  }
 catch (  IOException e) {
    throw new GenericException(e);
  }
}