Program: 188760
Project: 188760
Buggy source:
public static StreamResponse aipsAipIdPreservationMetadataGet(String aipId,String start,String limit) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException {
  List<Representation> representations=null;
  CloseableIterable<PreservationMetadata> preservationFiles=null;
  try {
    ModelService model=RodaCoreFactory.getModelService();
    StorageService storage=RodaCoreFactory.getStorageService();
    representations=model.retrieveAIP(aipId).getRepresentations();
    Pair<Integer,Integer> pagingParams=ApiUtils.processPagingParams(start,limit);
    int startInt=pagingParams.getFirst();
    int limitInt=pagingParams.getSecond();
    int counter=0;
    List<ZipEntryInfo> zipEntries=new ArrayList<ZipEntryInfo>();
    boolean includeRepresentations=true;
    preservationFiles=model.listPreservationMetadata(aipId,includeRepresentations);
    for (    PreservationMetadata preservationFile : preservationFiles) {
      if (counter >= startInt && (counter <= limitInt || limitInt == -1)) {
        StoragePath storagePath=ModelUtils.getPreservationMetadataStoragePath(preservationFile);
        Binary binary=storage.getBinary(storagePath);
        if (preservationFile.getRepresentationId() != null) {
          ZipEntryInfo info=new ZipEntryInfo(preservationFile.getRepresentationId() + File.separator + storagePath.getName(),binary.getContent());
          zipEntries.add(info);
        }
      }
 else {
        break;
      }
      counter++;
    }
    return createZipStreamResponse(zipEntries,aipId);
  }
  finally {
    IOUtils.closeQuietly(preservationFiles);
  }
}

Fixed version (ground truth):
public static StreamResponse aipsAipIdPreservationMetadataGet(String aipId,String start,String limit) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException {
  List<Representation> representations=null;
  CloseableIterable<PreservationMetadata> preservationFiles=null;
  try {
    ModelService model=RodaCoreFactory.getModelService();
    StorageService storage=RodaCoreFactory.getStorageService();
    representations=model.retrieveAIP(aipId).getRepresentations();
    Pair<Integer,Integer> pagingParams=ApiUtils.processPagingParams(start,limit);
    int startInt=pagingParams.getFirst();
    int limitInt=pagingParams.getSecond();
    int counter=0;
    List<ZipEntryInfo> zipEntries=new ArrayList<ZipEntryInfo>();
    boolean includeRepresentations=true;
    preservationFiles=model.listPreservationMetadata(aipId,includeRepresentations);
    for (    PreservationMetadata preservationFile : preservationFiles) {
      if (counter >= startInt && (counter <= limitInt || limitInt == -1)) {
        StoragePath storagePath=ModelUtils.getPreservationMetadataStoragePath(preservationFile);
        Binary binary=storage.getBinary(storagePath);
        if (preservationFile.getRepresentationId() != null) {
          ZipEntryInfo info=new ZipEntryInfo(preservationFile.getRepresentationId() + File.separator + StringUtils.join(storagePath.getDirectoryPath(),File.separator)+ File.separator+ storagePath.getName(),binary.getContent());
          zipEntries.add(info);
        }
      }
 else {
        break;
      }
      counter++;
    }
    return createZipStreamResponse(zipEntries,aipId);
  }
  finally {
    IOUtils.closeQuietly(preservationFiles);
  }
}