Skip to content

[WFLY-20988] Followup improvements of Jakarta EE 11 JPA / CDI integration for WildFly Preview - #19232

Merged
bstansberry merged 3 commits into
wildfly:mainfrom
scottmarlow:WFLY-20988_improvements_cdi_persistence
Oct 9, 2025
Merged

bstansberry merged 3 commits into
wildfly:mainfrom
scottmarlow:WFLY-20988_improvements_cdi_persistence

Conversation

@scottmarlow

Copy link
Copy Markdown
Contributor

weldCapability.get().registerExtensionInstance(persistenceCdiExtension, deploymentUnit);
else {
// ensure that other threads use the service that was loaded in a different thread.
persistenceCdiExtension = deploymentUnit.getAttachment(JpaAttachments.AFTER_BEAN_DISCOVERY_ATTACHMENT_KEY);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change ensures that the other threads register the persistence units with the persistenceCdiExtension (service) actually registered as a CDI extension (e.g. via the weldCapability.get().registerExtensionInstance(persistenceCdiExtension, deploymentUnit) call in a different thread)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it doesn't look like I finished my review on this.

This still is quite correct. When you have time to discuss it, ping me in chat. I need to understand better. If concurrency is a concern we need have some kind of shared lock per-deployment. I'm not sure that concurrency is a concern here though as I see other places in the source which don't seem concerned about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference the previous feedback was:

The issue though is that if deploymentUnit.putAttachment(JpaAttachments.AFTER_BEAN_DISCOVERY_ATTACHMENT_KEY, persistenceCdiExtension) returns a value, you'd be executing the register() on the wrong instance.

Yes, I see it now! Originally, we had a synchronize on the top level deployment unit (e.g. ear, standalone war, standalone jar):

synchronized (deploymentUnit) { // protect against multiple subdeployment threads registering the persistenceCdiExtension at same time

We could use a different object to lock on than the (top most level) DeploymentUnit but yes having a shared lock per (top level) deployment is the right idea.

…tence unit deployments don't get a NPE which likely would of happened eventually

Signed-off-by: Scott Marlow <[email protected]>
Comment on lines +774 to +775
// @Message(id = 80, value = "Found more than one %s service for application deployment %s")
// RuntimeException foundMoreThanOneCdiExtensionService(Class<?> serviceClassName, ClassLoader module);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific case we can actually delete this since it has never been in a final release.

Signed-off-by: Scott Marlow <[email protected]>
@scottmarlow
scottmarlow force-pushed the WFLY-20988_improvements_cdi_persistence branch from 3514dc3 to 9f951ea Compare October 7, 2025 23:42
@scottmarlow scottmarlow changed the title [WFLY-20988] Followup improvments of Jakarta EE 11 JPA / CDI integration for WildFly Preview [WFLY-20988] Followup improvements of Jakarta EE 11 JPA / CDI integration for WildFly Preview Oct 8, 2025
@jamezp jamezp added the ready-for-merge Only for use by those with merge permissions! label Oct 9, 2025
@bstansberry bstansberry removed the ready-for-merge Only for use by those with merge permissions! label Oct 9, 2025
@bstansberry

Copy link
Copy Markdown
Contributor

@jamezp @scottmarlow I removed the ready-for-merge label for this because yesterday I ran two other WFP+JPA PRs in a combo PR against the EE 11 branch, and this wasn't part of it, since it wasn't approved. Those tests passed.

So I'll merge those two and then get more testing of this to ensure the combo isn't a problem

@jamezp

jamezp commented Oct 9, 2025

Copy link
Copy Markdown
Member

Ah, sorry. I should have thought about kicking off an EE11 job.

@bstansberry

Copy link
Copy Markdown
Contributor

That's ok; I'm mostly wanting to be sure the combo of the 3 related PRs is ok. I'll do that job now.

@bstansberry bstansberry mentioned this pull request Oct 9, 2025
@bstansberry

Copy link
Copy Markdown
Contributor

#19269

@bstansberry
bstansberry merged commit f8c88e8 into wildfly:main Oct 9, 2025
@bstansberry

Copy link
Copy Markdown
Contributor

Thanks @scottmarlow and @jamezp

@scottmarlow
scottmarlow deleted the WFLY-20988_improvements_cdi_persistence branch October 9, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants