Stop mutating shared ParsedPersistenceXmlDescriptor in build steps - #51628
Stop mutating shared ParsedPersistenceXmlDescriptor in build steps#51628Pepo48 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Stops mutating the shared ParsedPersistenceXmlDescriptor during Quarkus build steps by switching entity registration to Quarkus’ JPA model contribution mechanism (closes #47482).
Changes:
- Introduces
JpaModelPersistenceUnitContributionBuildItemto contribute entities instead of mutating the parsed persistence unit descriptor. - Refactors default PU entity discovery to collect entities and emit a contribution build item.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| List<String> additionalEntities = new ArrayList<>(); | ||
| for (AnnotationInstance annotation : annotations) { | ||
| AnnotationTarget target = annotation.target(); | ||
| String targetName = target.asClass().name().toString(); | ||
|
|
||
| if (!userManagedEntities.contains(targetName) | ||
| && (!targetName.startsWith("org.keycloak") || targetName.startsWith("org.keycloak.testsuite"))) { | ||
| descriptor.addClasses(targetName); | ||
| additionalEntities.add(targetName); | ||
| } | ||
| } | ||
|
|
||
| if (!additionalEntities.isEmpty()) { | ||
| jpaModelPuContributions.produce(new JpaModelPersistenceUnitContributionBuildItem( | ||
| descriptor.getName(), descriptor.getPersistenceUnitRootUrl(), | ||
| additionalEntities, Collections.emptyList())); | ||
| } |
There was a problem hiding this comment.
Not valid - it doesn't account for the constructor's defensive copy into a TreeSet.
| jpaModelPuContributions.produce(new JpaModelPersistenceUnitContributionBuildItem( | ||
| descriptor.getName(), descriptor.getPersistenceUnitRootUrl(), | ||
| additionalEntities, Collections.emptyList())); |
|
@Pepo48 I look at that Base IT (4) and it looks suspicious as there is some DB failure, please investigate. |
…lDescriptor Closes keycloak#47482 Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
…lDescriptor Closes keycloak#47482 Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
| @Override | ||
| public List<String> getManagedClassNames() { | ||
| return List.copyOf(super.getManagedClassNames()); | ||
| } |
Closes #47482