Project: clover
Issue CLOV-1398: Java 1.8 Exceptions not being propagated correctly
I have the following test stub (src/main/java) {code:java} public final class TestStub { TestStub() { throw new IllegalArgumentException(); } public static void getHandler() { new HashMap<>().computeIfAbsent(String.class, t -> new TestStub()); } } {code} And the following test (src/test/java) {code:java} public class FooTest { @Test(expected = IllegalArgumentException.class) public void test0() { TestStub.getHandler(); } } {code} Using maven It runs fine using "clean install" however using clover I get the following exception {noformat} java.lang.reflect.UndeclaredThrowableException com.sun.proxy.$Proxy12.apply(Unknown Source) java.util.HashMap.computeIfAbsent(HashMap.java:1118) org.cakeframework.internal.container.TestStub.getHandler(TestStub.java:26) org.cakeframework.internal.container.FooTest.test0(FooTest.java:29) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:483) org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19) org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) org.junit.runners.ParentRunner.run(ParentRunner.java:309) org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264) org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.reflect.InvocationTargetException sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:483) org.cakeframework.internal.container.TestStub$__CLR3_2_0wqwqhpd53be5$1.invoke(TestStub.java:20)	... 28 more Caused by: java.lang.IllegalArgumentException org.cakeframework.internal.container.TestStub.(TestStub.java:22) org.cakeframework.internal.container.TestStub.lambda$getHandler$6(TestStub.java:26) org.cakeframework.internal.container.TestStub$$Lambda$13/1227074340.apply(Unknown Source)	... 33 more {noformat} If I replace with a standard anonymous class implementing java.util.function.Function it runs fine
Story points: 3