BATCHEE-133 fix remote stop
starting a batch with
./bin/batchee.sh start -archive testbatch.war -name testjob -socket 8900
and stopping with
./bin/batchee.sh -id 0 -socket 8900
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/callback/SimpleJobExecutionCallbackService.java b/jbatch/src/main/java/org/apache/batchee/container/services/callback/SimpleJobExecutionCallbackService.java
index faf0f60..f98eedd 100644
--- a/jbatch/src/main/java/org/apache/batchee/container/services/callback/SimpleJobExecutionCallbackService.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/callback/SimpleJobExecutionCallbackService.java
@@ -46,12 +46,12 @@
@Override
public void waitFor(final long id) {
- Collection<CountDownLatch> toRealease = waiters.remove(id);
- if (toRealease == null) {
- toRealease = new CopyOnWriteArrayList<CountDownLatch>();
- final Collection<CountDownLatch> existing = waiters.putIfAbsent(id, toRealease);
+ Collection<CountDownLatch> toRelease = waiters.get(id);
+ if (toRelease == null) {
+ toRelease = new CopyOnWriteArrayList<CountDownLatch>();
+ final Collection<CountDownLatch> existing = waiters.putIfAbsent(id, toRelease);
if (existing != null) {
- toRealease = existing;
+ toRelease = existing;
}
}
@@ -63,9 +63,10 @@
}
final CountDownLatch latch = new CountDownLatch(1);
- toRealease.add(latch);
+ toRelease.add(latch);
try {
latch.await();
+ waiters.remove(id);
} catch (final InterruptedException e) {
throw new BatchContainerRuntimeException(e);
}