eclipse-ee4j / eclipse-ee4j/jersey
ValidationException when interface with no methods is included in the class hirarchy
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/eclipse-ee4j/jersey/blob/9cfc243432408193f8ca42c9cd4796b51820ff17/ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/ValidateOnExecutionHandler.java#L151
The following example throws a ValidationException
```java
public class Asd {
public interface Interface1 {
@ValidateOnExecution
Response someMethod();
}
public interface Interface2 extends Interface1 {
}
public interface Interface3 extends Interface2 {
Response someMethod();
}
}
@Path("asd")
@Produces(MediaType.APPLICATION_JSON)
@Provider
public class Endpoint implements Asd.Interface3 {
@GET
@Override
@Valid
public Response someMethod() {
return Response.noContent().build();
}
}
```
It seems that ```AccessController.doPrivileged(ReflectionHelper.findMethodOnClassPA(overriddenClass, method))``` returns the parent's method when it's not found in the given ```overriddenClass```.
The problem is that, as the ```@ValidateOnExecution``` annotation is already found in the parent class, and ```processAnnotation(Method, Deque>, boolean)``` is checking whether overridden methods are also annotated with the ```@ValidateOnExecution```, then the exception is thrown.
Note that this also happens if ```Asd.Interface3``` does not include any method.
Contributor guide
Assessment
This issue has not been assessed yet.