@@ -257,26 +257,17 @@ public BarChild apply(Foo unused) {
257
257
assertSame (barChild , bar );
258
258
}
259
259
260
- @ AndroidIncompatible // b/391667564: crashes from stack overflows
261
260
@ J2ktIncompatible
262
261
@ GwtIncompatible // StackOverflowError
263
262
public void testTransform_stackOverflow () throws Exception {
264
- {
265
- /*
266
- * Initialize all relevant classes before running the test, which may otherwise poison any
267
- * classes it is trying to load during its stack overflow.
268
- */
269
- SettableFuture <Object > root = SettableFuture .create ();
270
- ListenableFuture <Object > unused = transform (root , identity (), directExecutor ());
271
- root .set ("foo" );
272
- }
273
-
274
- SettableFuture <Object > root = SettableFuture .create ();
275
- ListenableFuture <Object > output = root ;
276
- for (int i = 0 ; i < 10000 ; i ++) {
277
- output = transform (output , identity (), directExecutor ());
278
- }
279
- assertThrows (StackOverflowError .class , () -> root .set ("foo" ));
263
+ SettableFuture <Object > input = SettableFuture .create ();
264
+ ListenableFuture <Object > output = transform (input , identity (), directExecutor ());
265
+ output .addListener (
266
+ () -> {
267
+ throw new StackOverflowError ();
268
+ },
269
+ directExecutor ());
270
+ assertThrows (StackOverflowError .class , () -> input .set ("foo" ));
280
271
}
281
272
282
273
public void testTransform_errorAfterCancellation () throws Exception {
@@ -469,26 +460,17 @@ public ListenableFuture<Bar> apply(Foo unused) {
469
460
assertFalse (((AbstractFuture <?>) f2 ).wasInterrupted ());
470
461
}
471
462
472
- @ AndroidIncompatible // b/391667564: crashes from stack overflows
473
463
@ J2ktIncompatible
474
464
@ GwtIncompatible // StackOverflowError
475
465
public void testTransformAsync_stackOverflow () throws Exception {
476
- {
477
- /*
478
- * Initialize all relevant classes before running the test, which may otherwise poison any
479
- * classes it is trying to load during its stack overflow.
480
- */
481
- SettableFuture <Object > root = SettableFuture .create ();
482
- ListenableFuture <Object > unused = transformAsync (root , asyncIdentity (), directExecutor ());
483
- root .set ("foo" );
484
- }
485
-
486
- SettableFuture <Object > root = SettableFuture .create ();
487
- ListenableFuture <Object > output = root ;
488
- for (int i = 0 ; i < 10000 ; i ++) {
489
- output = transformAsync (output , asyncIdentity (), directExecutor ());
490
- }
491
- assertThrows (StackOverflowError .class , () -> root .set ("foo" ));
466
+ SettableFuture <Object > input = SettableFuture .create ();
467
+ ListenableFuture <Object > output = transformAsync (input , asyncIdentity (), directExecutor ());
468
+ output .addListener (
469
+ () -> {
470
+ throw new StackOverflowError ();
471
+ },
472
+ directExecutor ());
473
+ assertThrows (StackOverflowError .class , () -> input .set ("foo" ));
492
474
}
493
475
494
476
public void testTransformAsync_errorAfterCancellation () throws Exception {
@@ -1305,27 +1287,18 @@ public void testCatching_customTypeNoMatch() throws Exception {
1305
1287
assertThat (expected ).hasCauseThat ().isInstanceOf (RuntimeException .class );
1306
1288
}
1307
1289
1308
- @ AndroidIncompatible // b/391667564: crashes from stack overflows
1309
1290
@ J2ktIncompatible
1310
1291
@ GwtIncompatible // StackOverflowError
1311
1292
public void testCatching_stackOverflow () throws Exception {
1312
- {
1313
- /*
1314
- * Initialize all relevant classes before running the test, which may otherwise poison any
1315
- * classes it is trying to load during its stack overflow.
1316
- */
1317
- SettableFuture <Object > root = SettableFuture .create ();
1318
- ListenableFuture <Object > unused =
1319
- catching (root , MyException .class , identity (), directExecutor ());
1320
- root .setException (new MyException ());
1321
- }
1322
-
1323
- SettableFuture <Object > root = SettableFuture .create ();
1324
- ListenableFuture <Object > output = root ;
1325
- for (int i = 0 ; i < 10000 ; i ++) {
1326
- output = catching (output , MyException .class , identity (), directExecutor ());
1327
- }
1328
- assertThrows (StackOverflowError .class , () -> root .setException (new MyException ()));
1293
+ SettableFuture <Object > input = SettableFuture .create ();
1294
+ ListenableFuture <Object > output =
1295
+ catching (input , MyException .class , identity (), directExecutor ());
1296
+ output .addListener (
1297
+ () -> {
1298
+ throw new StackOverflowError ();
1299
+ },
1300
+ directExecutor ());
1301
+ assertThrows (StackOverflowError .class , () -> input .setException (new MyException ()));
1329
1302
}
1330
1303
1331
1304
public void testCatching_errorAfterCancellation () throws Exception {
@@ -1435,27 +1408,18 @@ public void testCatchingAsync_customTypeNoMatch() throws Exception {
1435
1408
assertThat (expected ).hasCauseThat ().isInstanceOf (RuntimeException .class );
1436
1409
}
1437
1410
1438
- @ AndroidIncompatible // b/391667564: crashes from stack overflows
1439
1411
@ J2ktIncompatible
1440
1412
@ GwtIncompatible // StackOverflowError
1441
1413
public void testCatchingAsync_stackOverflow () throws Exception {
1442
- {
1443
- /*
1444
- * Initialize all relevant classes before running the test, which may otherwise poison any
1445
- * classes it is trying to load during its stack overflow.
1446
- */
1447
- SettableFuture <Object > root = SettableFuture .create ();
1448
- ListenableFuture <Object > unused =
1449
- catchingAsync (root , MyException .class , asyncIdentity (), directExecutor ());
1450
- root .setException (new MyException ());
1451
- }
1452
-
1453
- SettableFuture <Object > root = SettableFuture .create ();
1454
- ListenableFuture <Object > output = root ;
1455
- for (int i = 0 ; i < 10000 ; i ++) {
1456
- output = catchingAsync (output , MyException .class , asyncIdentity (), directExecutor ());
1457
- }
1458
- assertThrows (StackOverflowError .class , () -> root .setException (new MyException ()));
1414
+ SettableFuture <Object > input = SettableFuture .create ();
1415
+ ListenableFuture <Object > output =
1416
+ catchingAsync (input , MyException .class , asyncIdentity (), directExecutor ());
1417
+ output .addListener (
1418
+ () -> {
1419
+ throw new StackOverflowError ();
1420
+ },
1421
+ directExecutor ());
1422
+ assertThrows (StackOverflowError .class , () -> input .setException (new MyException ()));
1459
1423
}
1460
1424
1461
1425
public void testCatchingAsync_errorAfterCancellation () throws Exception {
0 commit comments