Skip to content

Extract ResourceEntityResolver HTTPS schema resolution fallback #29697

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

Closed

Conversation

simonbasle
Copy link
Contributor

This commit extracts the DTD/XSD remote lookup fallback from the
resolveEntity method into a protected method.

A warn logging statement is added to the extracted fallback in order to
make it clear that remote lookup happened.

Overriding the protected method would allow users to avoid this fallback
entirely if it isn't desirable, without the need to duplicate the local
resolution code.

Fixes gh-29662.

This commit extracts the DTD/XSD remote lookup fallback from the
resolveEntity method into a protected method.

A warn logging statement is added to the extracted fallback in order to
make it clear that remote lookup happened.

Overriding the protected method would allow users to avoid this fallback
entirely if it isn't desirable, without the need to duplicate the local
resolution code.

Fixes spring-projectsgh-29662.
@simonbasle
Copy link
Contributor Author

simonbasle commented Dec 16, 2022

draft because I'm wondering about the extracted method's javadoc: it should probably list returning nulland throwing as override possibilities, but I'm not sure how to explain what each of these options does in a nutshell. would appreciate suggestions here

@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Dec 16, 2022
@sbrannen sbrannen added this to the 6.0.4 milestone Dec 16, 2022
@sbrannen sbrannen self-requested a review December 16, 2022 12:08
@scantor
Copy link

scantor commented Dec 16, 2022

draft because I'm wondering about the extracted method's javadoc: it should probably list returning nulland throwing as override possibilities, but I'm not sure how to explain what each of these options does in a nutshell. would appreciate suggestions here

Refer to the EntityResolver's resolveEntity semantics as a reference perhaps? That's ultimately what you're triggering.

@sbrannen
Copy link
Member

draft because I'm wondering about the extracted method's javadoc: it should probably list returning nulland throwing as override possibilities, but I'm not sure how to explain what each of these options does in a nutshell. would appreciate suggestions here

Refer to the EntityResolver's resolveEntity semantics as a reference perhaps? That's ultimately what you're triggering.

Returning null will trigger the default behavior of the parser.

Throwing an exception should cause the parser to fail (and skip any attempt to load the remote resource).

We should introduce tests for both use cases.

@simonbasle simonbasle marked this pull request as ready for review December 16, 2022 15:57
@simonbasle simonbasle requested a review from sbrannen December 16, 2022 15:57
@sbrannen sbrannen changed the title Extract ResourceEntityResolver https resolution fallback Extract ResourceEntityResolver HTTPS schema resolution fallback Dec 17, 2022
sbrannen added a commit to sbrannen/spring-framework that referenced this pull request Dec 17, 2022
@sbrannen sbrannen closed this in 5965917 Dec 17, 2022
@sbrannen
Copy link
Member

This has been merged into main in 5965917 and revised in 8df4f92.

Thanks, and... congratulations on having your first PR merged into the code base! 👍

@simonbasle simonbasle deleted the 29662-entityresolverfallback branch April 18, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce hook in ResourceEntityResolver to override fallback to remote access for DTD/XSD resolution
3 participants