Skip to content

Commit 8dbd622

Browse files
committed
bug: #41
Added Try to catch any unforeseen exception when notifying the event listeners
1 parent 531d935 commit 8dbd622

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/javascalautils/concurrent/PromiseImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package javascalautils.concurrent;
1717

1818
import static javascalautils.TryCompanion.Failure;
19+
import static javascalautils.TryCompanion.Try;
1920
import static javascalautils.TryCompanion.Success;
2021

2122
import java.util.concurrent.atomic.AtomicBoolean;
@@ -160,7 +161,9 @@ public String toString() {
160161
*/
161162
private boolean tryComplete(Consumer<FutureImpl<T>> c) {
162163
if (completed.compareAndSet(false, true)) {
163-
c.accept(future);
164+
//This Try is only here to manage any unforeseen exception raised by the Future event listener
165+
//See issue#41
166+
Try(() -> c.accept(future));
164167
return true;
165168
}
166169
return false;

0 commit comments

Comments
 (0)