-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
3.0.10.Final, 3.6.2.Final
-
None
-
-
Compatibility/Configuration
-
Workaround Exists
-
package org.jboss.resteasy.spi; import org.junit.Test; import javax.ws.rs.ext.ContextResolver; public class ResteasyProviderFactoryTest { @Test public void testRegisterProviderAsLambda() throws Exception { ResteasyProviderFactory factory = new ResteasyProviderFactory(); factory.register((ContextResolver<String>) type -> "foo bar"); } }
Then it doesn't work:
java.lang.RuntimeException: Unable to instantiate ContextResolver at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProviderInstance(ResteasyProviderFactory.java:1814) at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProviderInstance(ResteasyProviderFactory.java:1728) at org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:2410) at org.jboss.resteasy.spi.ResteasyProviderFactoryTest.testRegisterProviderAsLambda(ResteasyProviderFactoryTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.junit.runner.JUnitCore.run(JUnitCore.java:130) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at org.jboss.resteasy.spi.ResteasyProviderFactory.addContextResolver(ResteasyProviderFactory.java:1124) at org.jboss.resteasy.spi.ResteasyProviderFactory.addContextResolver(ResteasyProviderFactory.java:1119) at org.jboss.resteasy.spi.ResteasyProviderFactory.addContextResolver(ResteasyProviderFactory.java:1114) at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProviderInstance(ResteasyProviderFactory.java:1808) ... 26 more
This seems to be because org.jboss.resteasy.util.Types#findInterfaceParameterizedTypes
doesnt work with lambdas.
I would have liked to submit a patch too, but that doesn't seem very trivial.
tries to resolve the generic type argument of a lambda.
- is duplicated by
-
RESTEASY-1725 Registering lambda context resolver results in ArrayIndexOutOfBoundsException
- Resolved