From b7d4f2e374232f1a0390ed35b9d29ca1757351b0 Mon Sep 17 00:00:00 2001 From: Stephen Salinas Date: Tue, 10 Jan 2017 17:05:15 -0500 Subject: [PATCH] missing tokens gives false positive end of content --- .../hubspot/singularity/resources/HistoryResource.java | 2 +- .../com/hubspot/singularity/resources/S3LogResource.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SingularityService/src/main/java/com/hubspot/singularity/resources/HistoryResource.java b/SingularityService/src/main/java/com/hubspot/singularity/resources/HistoryResource.java index e3f8a2fbe9..1b298d6d92 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/resources/HistoryResource.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/resources/HistoryResource.java @@ -236,7 +236,7 @@ public SingularityPaginatedResponse getTaskHistoryWith @Path("/request/{requestId}/tasks") @ApiOperation("Retrieve the history sorted by startedAt for all inactive tasks of a specific request.") public List getTaskHistoryForRequest( - @ApiParam("Request ID to match") @PathParam("requestId") String requestId, + @ApiParam("Request ID to match") @PathParam("resquestId") String requestId, @ApiParam("Optional deploy ID to match") @QueryParam("deployId") Optional deployId, @ApiParam("Optional runId to match") @QueryParam("runId") Optional runId, @ApiParam("Optional host to match") @QueryParam("host") Optional host, diff --git a/SingularityService/src/main/java/com/hubspot/singularity/resources/S3LogResource.java b/SingularityService/src/main/java/com/hubspot/singularity/resources/S3LogResource.java index 4f9afdb908..30d2a47916 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/resources/S3LogResource.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/resources/S3LogResource.java @@ -317,8 +317,10 @@ private List getS3LogsWithExecutorService(S3Configurat public List call() throws Exception { ListObjectsV2Request request = new ListObjectsV2Request().withBucketName(s3Bucket).withPrefix(s3Prefix); if (paginated) { + Optional token = Optional.absent(); if (search.getContinuationTokens().containsKey(key) && !Strings.isNullOrEmpty(search.getContinuationTokens().get(key).getValue())) { request.setContinuationToken(search.getContinuationTokens().get(key).getValue()); + token = Optional.of(search.getContinuationTokens().get(key)); } int targetResultCount = search.getMaxPerPage().or(DEFAULT_TARGET_MAX_RESULTS); request.setMaxKeys(targetResultCount); @@ -328,7 +330,8 @@ public List call() throws Exception { continuationTokens.putIfAbsent(key, new ContinuationToken(result.getNextContinuationToken(), true)); return Collections.emptyList(); } else { - if (incrementIfLessThan(resultCount, result.getObjectSummaries().size(), targetResultCount)) { + boolean addToList = incrementIfLessThan(resultCount, result.getObjectSummaries().size(), targetResultCount); + if (addToList) { continuationTokens.putIfAbsent(key, new ContinuationToken(result.getNextContinuationToken(), !result.isTruncated())); List objectSummaryHolders = new ArrayList<>(); for (S3ObjectSummary objectSummary : result.getObjectSummaries()) { @@ -336,11 +339,12 @@ public List call() throws Exception { } return objectSummaryHolders; } else { - continuationTokens.putIfAbsent(key, new ContinuationToken(null, false)); + continuationTokens.putIfAbsent(key, token.or(new ContinuationToken(null, false))); return Collections.emptyList(); } } } else { + continuationTokens.putIfAbsent(key, token.or(new ContinuationToken(null, false))); return Collections.emptyList(); } } else {