[jboss-jira] [JBoss JIRA] (WFLY-11956) @PostConstruct on @ApplicationScoped bean called too late in case @Valid is annotated on a business method
Brian Stansberry (Jira)
issues at jboss.org
Tue Apr 9 18:12:00 EDT 2019
[ https://issues.jboss.org/browse/WFLY-11956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brian Stansberry reassigned WFLY-11956:
---------------------------------------
Component/s: REST
Assignee: Alessio Soldano (was: Brian Stansberry)
[~asoldano] I'm going to pass this one to you as the attached logging.txt from the reproducer application shows resteasy as being centrally involved in the two unexpected invocations, as it's JaxrsInjectionTarget that is triggering validation of the bean.
org.jboss.weld.bean.ManagedBean.create calls JaxrsInjectionTarget.inject before it calls JaxrsInjectionTarget.postConstruct. It's the inject call that results in the "early" invocations of getHelloGreeting.
[~guillaume.smet] [~manovotn] FYI.
I don't know that what's being done here is necessarily wrong.
An aside from whether JaxrsInjectionTarget.inject should be validating before the @PostConstruct is the first stack trace is a bit funky, where the JPA (Hibernate) PersistenceUtilHelper ends up invoking getHelloGreeting.
> @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: Alessio Soldano
> 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