Details
Assignee
UnassignedUnassignedReporter
Matthias WelzMatthias WelzBug Testcase Reminder (view)
Bug reports should generally be accompanied by a test case!
Bug Testcase Reminder (edit)
Bug reports should generally be accompanied by a test case!
Participants
Guillaume SmetMatthias WelzPriority
Major
Details
Details
Assignee
Unassigned
UnassignedReporter
Matthias Welz
Matthias WelzBug Testcase Reminder (view)
Bug reports should generally be accompanied by a test case!
Bug Testcase Reminder (edit)
Bug reports should generally be accompanied by a test case!
Participants
Guillaume Smet
Matthias Welz
Priority
Created July 26, 2021 at 11:02 AM
Updated December 12, 2024 at 11:29 AM
According to JSR-380, bean validation constraints should be applied to interfaces and not to the implementation:
However, when using a simple example, the bean validation does not get executed:
public interface GreetingService { String greet(@NotEmpty @Size(max = 10) String who); } public class GreetingServiceImpl implements GreetingService { @Override public String greet(String who) { return String.format("Hello %s!", who); } } //... @Inject private GreetingService service; this.service.greet("thisisaverylongstring");
Only when adding another method to the GreetingServiceImpl class which has bean validation annotations, the valdiation works as expected:
public void foo(@NotNull String bar) { }
Possibly security related if users rely on bean validation to work in order to prevent invalid input.
Steps to reproduce:
Build the maven project in the attachment
Deploy to Java EE Server running Hibernate Validator
Navigate to URL [...]/greet/thisisaverylongstring
Expected: Error message about constraint violation
Actual: No error message - bean validation does not get executed
Workaround:
Uncomment the "foo" method in GreetingServiceImpl.java and everything works as expected.
Reproduced in WildFly 24.0.0.Final