[jboss-jira] [JBoss JIRA] (WFLY-11956) @PostConstruct on @ApplicationScoped bean called too late in case @Valid is annotated on a business method

Ronald Sigal (Jira) issues at jboss.org
Fri Apr 26 12:45:00 EDT 2019


    [ https://issues.jboss.org/browse/WFLY-11956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13727215#comment-13727215 ] 

Ronald Sigal commented on WFLY-11956:
-------------------------------------

Another question.

My understanding, based on [~guillaume.smet]'s clarification, is that 
{code}
    @Path("get")
    @GET
    @Valid
    @Produces(MediaType.APPLICATION_JSON)
    GreetingModel getHelloGreeting();
{code}
should lead to GreetingModel getting validated during the field/property validation phase, but a call like 
{code}
client.target("http://localhost:8081/get").request().get()
{code}
should, by default, *not* result in validating GreetingModel. 

Now, [~christian.zambrano] has pointed out that Phase 2 of the JAX-RS validation algorithm says, "Validate annotations on fields, property getters (if enabled) and the resource class." The parenthetical "if enabled" seems to contradict what I thought I understood.  Hmmm.

> @PostConstruct on @ApplicationScoped bean called too late in case @Valid is annotated on a business method
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: WFLY-11956
>                 URL: https://issues.jboss.org/browse/WFLY-11956
>             Project: WildFly
>          Issue Type: Bug
>          Components: Bean Validation, REST
>    Affects Versions: 16.0.0.Final
>            Reporter: Joerg Baesner
>            Assignee: Ronald Sigal
>            Priority: Major
>         Attachments: logging.txt, playground.zip
>
>
> Having a bean class with {{@ApplicationScoped}}, which has a {{@PostConstruct}} and is implementing  the following _Interface_:
> {code}
> @Path("/validated")
> public interface ValidatedJaxRsInterface {
>     
>     @GET
>     @Valid
>     @Produces(MediaType.APPLICATION_JSON)
>     GreetingModel getHelloGreeting();
> }
> {code}
> will result in calling the {{getHelloGreeting}} method of the implementation class twice *_before_* the {{@PostConstruct}} is getting executed.
> This can be reproduced with the attached reproducer application...



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list