Skip to content
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

HHH-18455 Strict XML validation compliance #9558

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jrenaat
Copy link
Contributor

@jrenaat jrenaat commented Jan 3, 2025

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-18455

@jrenaat jrenaat force-pushed the HHH-18455_strictxmlcompliance branch 2 times, most recently from 1f4b365 to 551447f Compare January 6, 2025 13:05
@jrenaat jrenaat requested a review from sebersole January 6, 2025 13:57
@jrenaat jrenaat marked this pull request as ready for review January 6, 2025 13:57
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps InputstreamRepeatableAccess would be a better name for this ...
I also wonder about what to do (if anything) with that chunk of memory the byte[] occupies, once this repeatable access is no longer needed; should there be some mechanism to release this?

Copy link
Member

Choose a reason for hiding this comment

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

Hey @jrenaat 👋🏻 😃

I remembered that we have something for XML validation in Validator code here: https://github.com/hibernate/hibernate-validator/blob/b14c620a3f7d93a322fa122b52e1b9e83c376c35/engine/src/main/java/org/hibernate/validator/internal/xml/mapping/MappingXmlParser.java#L98-L143

you'll see that that code relies on InputStream#mark()/InputStream#reset() instead of keeping all the file. And the way we make sure that these methods are "supported" by the stream is here:
https://github.com/hibernate/hibernate-validator/blob/b14c620a3f7d93a322fa122b52e1b9e83c376c35/engine/src/main/java/org/hibernate/validator/internal/engine/AbstractConfigurationImpl.java#L287

IDK if that would be applicable here or not, but I thought I'd let you know about it, and you can then decide 😃.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointers. I did consider the mark/reset approach but i'm not 100% it would work in our case, i think we actually need 2 separate inputstreams.

…to bind(InputStreamAccess, Origin) to allow repeatable access to the InputStream, needed for strict Jpa XML validation

HHH-18455 - Implement option to run strict JPA compliance validation

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
@jrenaat jrenaat force-pushed the HHH-18455_strictxmlcompliance branch from 551447f to 25cc853 Compare January 6, 2025 15:08
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.

2 participants