[jboss-jira] [JBoss JIRA] (WFLY-11956) @PostConstruct on @ApplicationScoped bean called too late in case @Valid is annotated on a business method
Christian Zambrano (Jira)
issues at jboss.org
Thu Apr 11 15:38:01 EDT 2019
[ https://issues.jboss.org/browse/WFLY-11956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13721309#comment-13721309 ]
Christian Zambrano edited comment on WFLY-11956 at 4/11/19 3:37 PM:
--------------------------------------------------------------------
Hi,
I am the person that reported the issue. When I opened the case with Redhat support, I did indicate that changing the name solved the issue but that is not a viable workaround because we have hundreds of rest endpoints methods that start with get.
Here are all the experiments I went through and the results:
Here are all the experiments I went through to try to understand this behavior:
1. Made the bean @ApplicationScope => Exhibits the behavior explained above
2. Made the bean @Stateless => Exhibits the behavior explained above
3. Made the bean @Singleton(from the ejb package) => Exhibits the behavior explained above
4. Made the bean @Singleton @Startup => Method is only called once and after the postconstruct as expected but the return value is not validated
5. Renamed the method to not start with 'get' => Method is only called once and after the postconstruct as expected
was (Author: christian.zambrano):
Hi,
I am the person that reported the issue. When I opened the case with Redhat support, I did indicate that changing the name solved the issue but that is not a viable workaround because we have hundreds of rest endpoints methods that start with get.
Here are all the experiements I went through and the results:
Here are all the experiments I went through to try to understand this behavior:
1. Made the bean @ApplicationScope => Exhibits the behavior explained above
2. Made the bean @Stateless => Exhibits the behavior explained above
3. Made the bean @Singleton(from the ejb package) => Exhibits the behavior explained above
4. Made the bean @Singleton @Startup => Method is only called once and after the postconstruct as expected but the return value is not validated
5. Renamed the method to not start with 'get' => Method is only called once and after the postconstruct as expected
> @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