Skip to content

Commit a42c6d6

Browse files
committed
Redoing changes
1 parent 3af9f42 commit a42c6d6

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
buildscript {
17-
ext.kotlin_version = '1.2.61'
17+
ext.kotlin_version = '1.2.70'
1818

1919
repositories {
2020
mavenCentral()
@@ -36,7 +36,7 @@ plugins {
3636

3737
allprojects {
3838
group = 'com.spectralogic.ds3'
39-
version = '5.0.4.5-debug'
39+
version = '5.0.4'
4040
}
4141

4242
subprojects {

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/PutJobManagement_Test.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,15 +2054,18 @@ public void testCancelingJob() throws URISyntaxException, InterruptedException {
20542054
final AtomicBoolean cancelHandlerCalled = new AtomicBoolean(false);
20552055
final CountDownLatch countDownLatch = new CountDownLatch(1);
20562056

2057-
writeJob.attachObjectCompletedListener(name -> {
2058-
try {
2059-
writeJob.cancel();
2060-
} catch (final FailedRequestException failedRequestException) {
2061-
caughtExceptionWhileCanceling.set(false);
2062-
} catch (final Throwable t) {
2063-
caughtExceptionWhileCanceling.set(true);
2064-
} finally {
2065-
countDownLatch.countDown();
2057+
final AtomicBoolean hasBeenCancelled = new AtomicBoolean(false);
2058+
writeJob.attachDataTransferredListener(dataTransferred -> {
2059+
if(hasBeenCancelled.compareAndSet(false, true)) {
2060+
new Thread(() -> {
2061+
try {
2062+
writeJob.cancel();
2063+
} catch (IOException e) {
2064+
fail();
2065+
} finally {
2066+
countDownLatch.countDown();
2067+
}
2068+
}).start();
20662069
}
20672070
});
20682071

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/strategy/transferstrategy/AbstractTransferStrategy.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,18 @@ private void transferAllJobBlobs() throws IOException {
135135

136136
final int numJobParts = Iterables.size(jobParts);
137137

138-
if (numJobParts == 0) {
138+
if (numJobParts <= 0) {
139139
break;
140140
}
141141

142-
final CountDownLatch countDownLatch = new CountDownLatch(numJobParts);
143-
transferJobParts(jobParts, countDownLatch, numBlobsRemaining, cancellationCheck);
144-
countDownLatch.await();
142+
final CountDownLatch jobPartsCompleteLatch = new CountDownLatch(numJobParts);
143+
transferJobParts(jobParts, jobPartsCompleteLatch, numBlobsRemaining, cancellationCheck);
144+
jobPartsCompleteLatch.await();
145145
} catch (final Ds3NoMoreRetriesException | FailedRequestException e) {
146146
emitFailureEvent(makeFailureEvent(failureActivity, e, firstChunk()));
147147
throw e;
148148
} catch (final InterruptedException | NoSuchElementException e) {
149+
LOG.warn("Thread was interrupted");
149150
Thread.currentThread().interrupt();
150151
} catch (final Throwable t) {
151152
emitFailureAndSetCachedException(t);
@@ -181,13 +182,13 @@ private synchronized void maybeSetCachedException(final Throwable t) {
181182
}
182183

183184
private void transferJobParts(final Iterable<JobPart> jobParts,
184-
final CountDownLatch countDownLatch,
185+
final CountDownLatch jobPartsCompleteLatch,
185186
final AtomicInteger numBlobsTransferred,
186187
final BooleanSupplier cancellationCheck) {
187188
for (final JobPart jobPart : jobParts) {
188189
if (executorService.isShutdown()) {
189190
LOG.debug("Executor service is shut down, decrementing countdown latch");
190-
countDownLatch.countDown();
191+
jobPartsCompleteLatch.countDown();
191192
} else {
192193
executorService.execute(() -> {
193194
try {
@@ -203,7 +204,7 @@ private void transferJobParts(final Iterable<JobPart> jobParts,
203204
} finally {
204205
jobState.blobTransferredOrFailed(jobPart.getBlob());
205206
numBlobsTransferred.decrementAndGet();
206-
countDownLatch.countDown();
207+
jobPartsCompleteLatch.countDown();
207208
}
208209
});
209210
}
@@ -245,7 +246,9 @@ public void close() {
245246
canceled = true;
246247
executorService.shutdown();
247248
try {
248-
executorService.awaitTermination(10000, TimeUnit.MILLISECONDS);
249+
if(!executorService.awaitTermination(10, TimeUnit.SECONDS)) {
250+
executorService.shutdownNow();
251+
};
249252
} catch (final InterruptedException e) {
250253
executorService.shutdownNow();
251254
}

0 commit comments

Comments
 (0)