Using both quarkus-resteasy-reactive and quarkus-smallrye-openapi leads to this exception at startup.
Caused by: java.lang.NullPointerException
at io.smallrye.openapi.runtime.io.response.ResponseReader.hasResponseCodeValue(ResponseReader.java:232)
at io.smallrye.openapi.jaxrs.JaxRsAnnotationScanner.processExceptionMappers(JaxRsAnnotationScanner.java:286)
at io.smallrye.openapi.jaxrs.JaxRsAnnotationScanner.processResourceMethods(JaxRsAnnotationScanner.java:237)
at io.smallrye.openapi.jaxrs.JaxRsAnnotationScanner.processResourceClass(JaxRsAnnotationScanner.java:217)
at io.smallrye.openapi.jaxrs.JaxRsAnnotationScanner.processResourceClasses(JaxRsAnnotationScanner.java:193)
at io.smallrye.openapi.jaxrs.JaxRsAnnotationScanner.scan(JaxRsAnnotationScanner.java:123)
at io.smallrye.openapi.runtime.scanner.OpenApiAnnotationScanner.scan(OpenApiAnnotationScanner.java:118)
at io.quarkus.smallrye.openapi.deployment.SmallRyeOpenApiProcessor.generateAnnotationModel(SmallRyeOpenApiProcessor.java:427)
at io.quarkus.smallrye.openapi.deployment.SmallRyeOpenApiProcessor.build(SmallRyeOpenApiProcessor.java:301)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:972)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
This is due to JaxRsAnnotationScanner picking up this class in RR:
package org.jboss.resteasy.reactive.server.spi;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
public interface ResteasyReactiveExceptionMapper<E extends Throwable> extends ExceptionMapper<E> {
/**
* Convenience method that allows for easy access to the request context
*/
Response toResponse(E exception, ServerRequestContext context);
}
And not being able to find its toResponse method and just crashing:
private Map<DotName, AnnotationInstance> processExceptionMappers(final AnnotationScannerContext context) {
Map<DotName, AnnotationInstance> exceptionHandlerMap = new HashMap<>();
Collection<ClassInfo> exceptionMappers = context.getIndex()
.getKnownDirectImplementors(JaxRsConstants.EXCEPTION_MAPPER);
for (ClassInfo classInfo : exceptionMappers) {
DotName exceptionDotName = classInfo.interfaceTypes()
.stream()
.filter(it -> it.name().equals(JaxRsConstants.EXCEPTION_MAPPER))
.filter(it -> it.kind() == Type.Kind.PARAMETERIZED_TYPE)
.map(Type::asParameterizedType)
.map(type -> type.arguments().get(0)) // ExceptionMapper<?> has a single type argument
.map(Type::name)
.findFirst()
.orElse(null);
if (exceptionDotName == null) {
continue;
}
MethodInfo toResponseMethod = classInfo.method(JaxRsConstants.TO_RESPONSE_METHOD_NAME,
Type.create(exceptionDotName, Type.Kind.CLASS));
if (ResponseReader.hasResponseCodeValue(toResponseMethod)) {
exceptionHandlerMap.put(exceptionDotName, ResponseReader.getResponseAnnotation(toResponseMethod));
}
}
return exceptionHandlerMap;
}
IMO this is a bug in SR-openapi, no @phillip-kruger ?
/cc @EricWittmann, @Ladicek, @MikeEdgar, @geoand, @jmartisk, @kenfinnigan, @phillip-kruger, @radcortez, @stuartwdouglas
Seems like it. I can look at it, but only next year. On PTO and away from a computer. Maybe @MikeEdgar can have a look?
Yes, I agree on the cause. I'll take a look later today/tomorrow.
Thanks a lot.
Thanks folks!
@MikeEdgar if we can get a SmallRye OpenAPI upgrade before tomorrow evening, we could include it in 1.11 Beta1.
Would be handy as it looks like it could block people willing to test RESTEasy Reactive.
If not, we will do without the upgrade!
Thanks!
PR smallrye/smallrye-open-api#602 is ready. Just need to have it reviewed and merged before doing a SmallRye OpenAPI release. I haven't gone through a release myself, so it might be best to pull in someone who is familiar with that process once the change is merged. @radcortez ?
Most helpful comment
Yes, I agree on the cause. I'll take a look later today/tomorrow.