Skip to content

Ignore GraalVM features in HibernateValidatorProcessor #47152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

gsmet
Copy link
Member

@gsmet gsmet commented Apr 3, 2025

Fixes #47033

if (Modifier.isAbstract(implementor.flags())) {
// we can avoid adding the abstract classes here: either they are parent classes
// and they will be dealt with by Hibernate Validator or they are child classes
// without any proper implementation and we can ignore them.
continue;
}
if (isInGraalVMFeature(indexView, implementor)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking whether we could say something like:

if (hasAnyConstraints(indexView, implementor)) {

If there are no constraints, there's nothing to cascade into, right? But I don't remember if we need to keep the classes without constraints.. will try to take a look later

Copy link
Member Author

@gsmet gsmet Apr 3, 2025

Choose a reason for hiding this comment

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

I think:

  • if the class is a leaf class
  • it doesn't have any constraints

we can skip it.

So I think we could go with your approach... but... I would still try to exclude the Feature classes as you never know if someone adds a @NotNull by mistake.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah +1 just to be safe

Copy link
Member Author

Choose a reason for hiding this comment

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

I let you check that excluding the leaf classes without constraints would be fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes 👍🏻 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

ok checked aand that won't fly 🙈:

Validator validator = validator( Set.of( A.class ) );

assertThat( validator.validate( new A() ) ).containsOnlyViolations(
		violationOf( NotNull.class ).withProperty( "name" )
);

// fails as we get the `UninitializedBeanMetaData` and hence no constraints ... 
assertThat( validator.validate( new B() ) ).containsOnlyViolations(
		violationOf( NotNull.class ).withProperty( "name" )
);

If we skip the class, even if it's a leaf with no constraints (or if it's anywhere in the hierarchy for that matter), we will end up having the UninitializedBeanMetaData for it once someone wants to validate an instance of it and it simply has 0 constraints (the ones from the super classes are there).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should have started with: WTH is this class in the index? I wouldn't expect it to be.

Copy link
Member Author

Choose a reason for hiding this comment

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

@gsmet gsmet force-pushed the hv-ignore-graalvm-feature branch from 9d8705d to 2925889 Compare April 7, 2025 16:16
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/graphql area/platform Issues related to definition and interaction with Quarkus Platform area/smallrye labels Apr 7, 2025
@gsmet
Copy link
Member Author

gsmet commented Apr 7, 2025

@marko-bekhta I just pushed an updated version on top of @Ladicek 's work in #47213 .

I will rebase and get it out of draft once the Jandex update PR is merged.

@gsmet gsmet force-pushed the hv-ignore-graalvm-feature branch from 2925889 to 9fe45f2 Compare April 7, 2025 18:20
@gsmet gsmet marked this pull request as ready for review April 7, 2025 18:21

This comment has been minimized.

@gsmet gsmet force-pushed the hv-ignore-graalvm-feature branch from 9fe45f2 to 27b475b Compare April 8, 2025 09:03
Copy link

quarkus-bot bot commented Apr 8, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 27b475b.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@gsmet
Copy link
Member Author

gsmet commented Apr 8, 2025

@marko-bekhta I'm interested in your review!

Copy link
Contributor

@marko-bekhta marko-bekhta left a comment

Choose a reason for hiding this comment

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

looks nice! 🎉

@gsmet gsmet merged commit b97c209 into quarkusio:main Apr 8, 2025
30 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.22 - main milestone Apr 8, 2025
@gsmet gsmet modified the milestones: 3.22 - main, 3.21.2 Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/graphql area/hibernate-validator Hibernate Validator area/platform Issues related to definition and interaction with Quarkus Platform area/smallrye kind/bugfix triage/backport-3.20
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native compilation failure using some extensions and bean validation
2 participants