vʌvr (formerly called Javaslang) is a non-commercial, non-profit object-functional library that runs with Java 8+. It aims to reduce the lines of code and increase code quality.
@Test
public void shouldApplyThrowingCheckedConsumer() {
final CheckedConsumer<?> f = t -> { throw new Error(); };
try {
f.accept(null);
fail("should have thrown");
} catch(Throwable x) {
// ok
}
}
Since AssertionError is-a Throwable, this test would pass, even if f.accept() didn't throw an error. I don't know how many instances of this problem there are throughout the code base.
On the one hand, it seems impossible to cause this problem in this context; however, the general pattern is a mistake.
Example:
Since
AssertionError
is-aThrowable
, this test would pass, even iff.accept()
didn't throw an error. I don't know how many instances of this problem there are throughout the code base.On the one hand, it seems impossible to cause this problem in this context; however, the general pattern is a mistake.