Description
openedon Oct 30, 2020
Describe the bug
After trying to upgrade to Quarkus 1.9.x (1.9.1) I've seen there were some changes (regressions?) to the validation behaviour. It seems that the validation does not work for interface methods with default implementation. This worked in the previous verisons of Quarkus (e.g. 1.6.1).
Expected behavior
JAX-RS validation should work for interface methods with default implementation.
To Reproduce
I've started the project with this command and made some modifications:
mvn io.quarkus:quarkus-maven-plugin:1.9.1.Final:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=validation-quickstart \
-DclassName="org.acme.validation.BookResource" \
-Dpath="/books" \
-Dextensions="resteasy-jsonb, hibernate-validator"
BookResource.java
package org.acme.validation;
import javax.validation.constraints.NotBlank;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/books")
public interface BookResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("{user}")
String helloUser(@PathParam("user") String user);
@GET
@Produces(MediaType.TEXT_PLAIN)
default String hello(@NotBlank(message = "Required") @CookieParam("user") String user) {
System.out.println("HELLO WORLD: " + user);
return helloUser(user);
}
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("works")
String thisOneWorks(@NotBlank(message = "Required") @CookieParam("user") String user);
}
BookResourceImpl.java
package org.acme.validation;
public class BookResourceImpl implements BookResource {
@Override
public String helloUser(String user) {
return "hello " + user;
}
@Override
public String thisOneWorks(String user) {
return "hello " + user;
}
}
Visit http://localhost:8080/books and you should see:
hello null
Visit http://localhost:8080/books/works and you should see:
[PARAMETER]
[thisOneWorks.user]
[Required]
[]
☝️ both responses should actually look like this (being validated).
Environment (please complete the following information):
- Quarkus version or git rev: 1.9.1