File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
test/com/linkedin/parseq/promise Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -344,7 +344,6 @@ public void onResolved(Promise<String> promise)
344
344
assertEquals ("Done!" , promise .get ());
345
345
}
346
346
347
-
348
347
@ Test
349
348
public void testListenerThrowsError () throws InterruptedException
350
349
{
@@ -364,4 +363,24 @@ public void onResolved(Promise<String> promise)
364
363
assertTrue (promise .await (5 , TimeUnit .SECONDS ));
365
364
assertEquals ("Done!" , promise .get ());
366
365
}
366
+
367
+ @ Test
368
+ public void testListenerThrowsErrorAfterPromiseDone () throws InterruptedException
369
+ {
370
+ // This test ensures that we catch and do not rethrow errors from listeners
371
+ // even if they are added after the promise is done.
372
+ final SettablePromise <String > promise = Promises .settable ();
373
+ promise .done ("Done!" );
374
+ assertTrue (promise .await (5 , TimeUnit .SECONDS ));
375
+
376
+ // This should not throw
377
+ promise .addListener (new PromiseListener <String >()
378
+ {
379
+ @ Override
380
+ public void onResolved (Promise <String > promise )
381
+ {
382
+ throw new Error ();
383
+ }
384
+ });
385
+ }
367
386
}
You can’t perform that action at this time.
0 commit comments