@@ -424,7 +424,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
424
424
implicit val success = Success .always
425
425
val innerPolicy = Directly ()
426
426
val counter = new AtomicInteger (0 )
427
- val future = FailFast (innerPolicy)(_ => false ) {
427
+ val future = FailFast (innerPolicy) {
428
+ case _ => false
429
+ } {
428
430
counter.incrementAndGet()
429
431
Future .successful(" yay!" )
430
432
}
@@ -435,15 +437,19 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
435
437
implicit val success = Success [Int ](_ == 3 )
436
438
val tries = forwardCountingFutureStream().iterator
437
439
val innerPolicy = Directly (3 )
438
- val future = FailFast (innerPolicy)(_ => false )(tries.next)
440
+ val future = FailFast (innerPolicy) {
441
+ case _ => false
442
+ } (tries.next)
439
443
future.map(result => assert(success.predicate(result) === true ))
440
444
}
441
445
442
446
it(" should fail when inner policy retries are exceeded" ) {
443
447
implicit val success = Success .always
444
448
val innerPolicy = Directly (3 )
445
449
val counter = new AtomicInteger (0 )
446
- val future = FailFast (innerPolicy)(_ => false ) {
450
+ val future = FailFast (innerPolicy) {
451
+ case _ => false
452
+ } {
447
453
counter.incrementAndGet()
448
454
Future .failed(new RuntimeException (" always failing" ))
449
455
}
@@ -457,7 +463,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
457
463
implicit val success = Success .always
458
464
val innerPolicy = Directly .forever
459
465
val counter = new AtomicInteger (0 )
460
- val future = FailFast (innerPolicy)(_ => true ) {
466
+ val future = FailFast (innerPolicy) {
467
+ case _ => true
468
+ } {
461
469
counter.incrementAndGet()
462
470
Future .failed(new RuntimeException (" always failing" ))
463
471
}
@@ -470,7 +478,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
470
478
implicit val success = Success .always
471
479
val innerPolicy = Directly .forever
472
480
val counter = new AtomicInteger (0 )
473
- val future = FailFast (innerPolicy)(_.getMessage == " 2" ) {
481
+ val future = FailFast (innerPolicy) {
482
+ case e => e.getMessage == " 2"
483
+ } {
474
484
val counterValue = counter.getAndIncrement()
475
485
Future .failed(new RuntimeException (counterValue.toString))
476
486
}
@@ -491,7 +501,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
491
501
Future (true )
492
502
}
493
503
val innerPolicy = Directly .forever
494
- val policy = FailFast (innerPolicy)(_ => false )
504
+ val policy = FailFast (innerPolicy) {
505
+ case _ => false
506
+ }
495
507
policy(run()).map { result =>
496
508
assert(result === true )
497
509
assert(retried.get() == 10000 )
@@ -510,7 +522,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
510
522
Future (true )
511
523
}
512
524
val innerPolicy = Pause .forever(1 .millis)
513
- val policy = FailFast (innerPolicy)(_ => false )
525
+ val policy = FailFast (innerPolicy) {
526
+ case _ => false
527
+ }
514
528
policy(run()).map { result =>
515
529
assert(result === true )
516
530
assert(retried.get() == 1000 )
@@ -529,7 +543,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
529
543
Future (true )
530
544
}
531
545
val innerPolicy = Backoff .forever(1 .millis)
532
- val policy = FailFast (innerPolicy)(_ => false )
546
+ val policy = FailFast (innerPolicy) {
547
+ case _ => false
548
+ }
533
549
policy(run()).map { result =>
534
550
assert(result === true )
535
551
assert(retried.get() == 5 )
@@ -548,7 +564,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
548
564
Future (true )
549
565
}
550
566
val innerPolicy = JitterBackoff .forever(1 .millis)
551
- val policy = FailFast (innerPolicy)(_ => false )
567
+ val policy = FailFast (innerPolicy) {
568
+ case _ => false
569
+ }
552
570
policy(run()).map { result =>
553
571
assert(result === true )
554
572
assert(retried.get() == 10 )
@@ -570,7 +588,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
570
588
val innerPolicy = When {
571
589
case _ : MyException => Directly .forever
572
590
}
573
- val policy = FailFast (innerPolicy)(_ => false )
591
+ val policy = FailFast (innerPolicy) {
592
+ case _ => false
593
+ }
574
594
policy(run()).map { result =>
575
595
assert(result === true )
576
596
assert(retried.get() == 10000 )
@@ -588,7 +608,9 @@ abstract class PolicySpec extends AsyncFunSpec with BeforeAndAfterAll {
588
608
val innerPolicy = When {
589
609
case _ : MyException => Directly .forever
590
610
}
591
- val policy = FailFast (innerPolicy)(_ => true )
611
+ val policy = FailFast (innerPolicy) {
612
+ case _ => true
613
+ }
592
614
policy(run()).failed.map { t =>
593
615
assert(t.getMessage === " my exception" )
594
616
assert(retried.get() == 1 )
0 commit comments