eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:
https://github.com/eclipse-ee4j/jersey/wiki
Other
690 stars 351 forks source link

Don't log warnings when only checking if CDI bean is also JAX-RS resource #3905

Open arjantijms opened 6 years ago

arjantijms commented 6 years ago

Jersey checks whether CDI beans are also JAX-RS resources, and if so modifies their injection points. For this check it shouldn't validate a CDI bean according to JAX-RS rules, if it's not a JAX-RS resource.

Practically, this often results in useless warnings, but it can even result in exceptions preventing deployments.

spericas commented 6 years ago

What are the details of the validation step done by Jersey?

arjantijms commented 6 years ago

@spericas

What are the details of the validation step done by Jersey?

Jersey creates a resource builder for the bean type using the IntrospectionModeller.

For this builder it indexes the path, method builders, child resource builders, resource methods, child resources and the sub resource locator, if any. If all of these are null or empty, the bean is not a JAX-RS resource.

While building this, it also does a number of validations. Among these are:

  1. non-public resource methods
  2. non-public sub-resource methods
  3. non-public sub-resource locators
  4. parameter hasn't got more than 1 *param annotation (e.g. HeaderParam and CookieParam)
  5. parameter is a concrete type (not a generic array or wildcard Type, or a type variable)
  6. if parameter is a parameterized type, that all type arguments are concrete
  7. instance field hasn't got more than 1 *param annotation (e.g. HeaderParam and CookieParam)
  8. instance field is a concrete type (not a generic array or wildcard Type, or a type variable)
  9. if instance field is a parameterized type, that all type arguments are concrete

Specifically this means that if it encounters a CDI interceptor bean, which uses the following well known pattern:

@Inject
@Intercepted
private Bean<?> interceptedBean;

Then the validator will log a warning for this, even though the interceptor has nothing to do with JAX-RS or Jersey.