Skip to content

Commit

Permalink
Merge pull request #19062 from geoand/#16122
Browse files Browse the repository at this point in the history
Avoid potential NPE `@Context ResourceInfo` is used
  • Loading branch information
stuartwdouglas authored Jul 28, 2021
2 parents ac739ae + 87e622f commit 856d0c3
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;
import org.jboss.resteasy.reactive.server.jaxrs.ResourceContextImpl;
import org.jboss.resteasy.reactive.server.jaxrs.SseImpl;
import org.jboss.resteasy.reactive.server.mapping.RuntimeResource;
import org.jboss.resteasy.reactive.server.spi.ServerRequestContext;

/**
Expand Down Expand Up @@ -86,13 +87,25 @@ Providers providers() {
@RequestScoped
@Produces
ResourceInfo resourceInfo() {
return getContext().getTarget().getLazyMethod();
RuntimeResource target = getTarget();
if (target != null) {
return target.getLazyMethod();
}
return SimpleResourceInfo.NullValues.INSTANCE;
}

@RequestScoped
@Produces
SimpleResourceInfo simplifiedResourceInfo() {
return getContext().getTarget().getSimplifiedResourceInfo();
RuntimeResource target = getTarget();
if (target != null) {
return target.getSimplifiedResourceInfo();
}
return SimpleResourceInfo.NullValues.INSTANCE;
}

private RuntimeResource getTarget() {
return getContext().getTarget();
}

@ApplicationScoped
Expand Down

0 comments on commit 856d0c3

Please sign in to comment.