Skip to content

Commit ef8f663

Browse files
committed
Make ConditionFactory safer to use in java 8
1 parent 5550079 commit ef8f663

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

awaitility/src/main/java/org/awaitility/core/ConditionFactory.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,7 @@ public void untilAsserted(final ThrowingRunnable assertion) {
805805
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
806806
*/
807807
public Integer untilAtomic(final AtomicInteger atomic, final Matcher<? super Integer> matcher) {
808-
return until(new CallableHamcrestCondition<>(new Callable<Integer>() {
809-
public Integer call() {
810-
return atomic.get();
811-
}
812-
}, matcher, generateConditionSettings()));
808+
return until(new CallableHamcrestCondition<>(() -> (Integer) atomic.get(), matcher, generateConditionSettings()));
813809
}
814810

815811
/**
@@ -827,7 +823,7 @@ public Integer call() {
827823
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
828824
*/
829825
public Long untilAtomic(final AtomicLong atomic, final Matcher<? super Long> matcher) {
830-
return until(new CallableHamcrestCondition<>(atomic::get, matcher, generateConditionSettings()));
826+
return until(new CallableHamcrestCondition<>(() -> (Long) atomic.get(), matcher, generateConditionSettings()));
831827
}
832828

833829
/**
@@ -844,7 +840,7 @@ public Long untilAtomic(final AtomicLong atomic, final Matcher<? super Long> mat
844840
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
845841
*/
846842
public void untilAtomic(final AtomicBoolean atomic, final Matcher<? super Boolean> matcher) {
847-
until(new CallableHamcrestCondition<>(atomic::get, matcher, generateConditionSettings()));
843+
until(new CallableHamcrestCondition<>(() -> (Boolean) atomic.get(), matcher, generateConditionSettings()));
848844
}
849845

850846
/**
@@ -879,7 +875,7 @@ public void untilFalse(final AtomicBoolean atomic) {
879875
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
880876
*/
881877
public void untilAdder(final LongAdder adder, final Matcher<? super Long> matcher) {
882-
until(new CallableHamcrestCondition<>(adder::longValue, matcher, generateConditionSettings()));
878+
until(new CallableHamcrestCondition<>(() -> (Long) adder.longValue(), matcher, generateConditionSettings()));
883879
}
884880

885881
/**
@@ -894,7 +890,7 @@ public void untilAdder(final LongAdder adder, final Matcher<? super Long> matche
894890
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
895891
*/
896892
public void untilAdder(final DoubleAdder adder, final Matcher<? super Double> matcher) {
897-
until(new CallableHamcrestCondition<>(adder::doubleValue, matcher, generateConditionSettings()));
893+
until(new CallableHamcrestCondition<>(() -> (Double) adder.doubleValue(), matcher, generateConditionSettings()));
898894
}
899895

900896
/**
@@ -909,7 +905,7 @@ public void untilAdder(final DoubleAdder adder, final Matcher<? super Double> ma
909905
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
910906
*/
911907
public void untilAccumulator(final LongAccumulator accumulator, final Matcher<? super Long> matcher) {
912-
until(new CallableHamcrestCondition<>(accumulator::longValue, matcher, generateConditionSettings()));
908+
until(new CallableHamcrestCondition<>(() -> (Long) accumulator.longValue(), matcher, generateConditionSettings()));
913909
}
914910

915911
/**
@@ -924,7 +920,7 @@ public void untilAccumulator(final LongAccumulator accumulator, final Matcher<?
924920
* @throws org.awaitility.core.ConditionTimeoutException If condition was not fulfilled within the given time period.
925921
*/
926922
public void untilAccumulator(final DoubleAccumulator accumulator, final Matcher<? super Double> matcher) {
927-
until(new CallableHamcrestCondition<>(accumulator::doubleValue, matcher, generateConditionSettings()));
923+
until(new CallableHamcrestCondition<>(() -> (Double) accumulator.doubleValue(), matcher, generateConditionSettings()));
928924
}
929925

930926
/**

0 commit comments

Comments
 (0)