Skip to content

Commit

Permalink
PAYARA-2956 - Fix warnings when checking CDI bean is JAX-RS resource (#…
Browse files Browse the repository at this point in the history
…3906)

Signed-off-by: arjantijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms authored and jansupol committed Jun 10, 2019
1 parent 44c05a5 commit 599a54d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -183,8 +183,10 @@ private void checkResourceClassSetters(final MethodList methodList,
method.getGenericParameterTypes()[0],
method.getAnnotations());
if (null != p) {
ResourceMethodValidator.validateParameter(p, method.getMethod(), method.getMethod().toGenericString(), "1",
if (!disableValidation) {
ResourceMethodValidator.validateParameter(p, method.getMethod(), method.getMethod().toGenericString(), "1",
InvocableValidator.isSingleton(handlerClass));
}

// we do not inject entity parameters into class instance fields and properties.
if (p.getSource() != Parameter.Source.ENTITY) {
Expand All @@ -208,8 +210,11 @@ private void checkResourceClassFields(final boolean encodedFlag,
field.getGenericType(),
field.getAnnotations());
if (null != p) {
ResourceMethodValidator.validateParameter(p, field, field.toGenericString(), field.getName(),
if (!disableValidation) {
ResourceMethodValidator.validateParameter(p, field, field.toGenericString(), field.getName(),
isInSingleton);
}

// we do not inject entity and unknown parameters into class instance fields and properties.
if (p.getSource() != Parameter.Source.ENTITY) {
injectableParameters.add(p);
Expand Down
Expand Up @@ -146,7 +146,10 @@ public Boolean apply(final Class<?> clazz) {
}
});

private final Cache<Class<?>, Boolean> jaxRsResourceCache = new Cache<>(clazz -> Resource.from(clazz) != null);
// Check first if a class is a JAX-RS resource, and only if so check with validation.
// This prevents unnecessary warnings being logged for pure CDI beans.
private final Cache<Class<?>, Boolean> jaxRsResourceCache = new Cache<>(
clazz -> Resource.from(clazz, true) != null && Resource.from(clazz) != null);

private final Hk2CustomBoundTypesProvider customHk2TypesProvider;
private final InjectionManagerStore injectionManagerStore;
Expand Down

0 comments on commit 599a54d

Please sign in to comment.