Skip to content

Disable XML bean definition loading when spring.xml.ignore is true #22093

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
wants to merge 1 commit into from
Closed

Disable XML bean definition loading when spring.xml.ignore is true #22093

wants to merge 1 commit into from

Conversation

sdeleuze
Copy link
Contributor

This commit allows to set the XmlBeanDefinitionReader field from BeanDefinitionLoader to null in a way that allows the GraalVM native compiler to remove it from the native image when the spring.xml.ignore flag introduced by spring-projects/spring-framework#25151 is set to true. The Groovy reader which relies on the XML one is disabled as well when the spring.xml.ignore flag is set to true.

The purpose of this change is to allow smaller footprint on native images without requiring to use GraalVM native substitutions which are unmaintainable by nature and also to increase the consistency between JVM and native images.

In order to effective, this optimization requires BeanDefinitionLoader class to be initialized at build time.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 24, 2020
This commit allows to set the XmlBeanDefinitionReader field from
BeanDefinitionLoader to null in a way that allows the GraalVM native
compiler to remove it from the native image when the spring.xml.ignore
flag introduced by spring-projects/spring-framework#25151
is set to true.

The purpose of this change is to allow smaller footprint on native
images without requiring to use GraalVM native substitutions
which are unmaintainable by nature and also to increase the consistency
between JVM and native images.

In order to effective, this optimization requires BeanDefinitionLoader
class to be initialized at build time.
@sdeleuze
Copy link
Contributor Author

sdeleuze commented Jun 24, 2020

I have updated this PR to focus only on disabling the XML reader as suggested by @wilkinsona. I was initially confused by the fact that private int load(GroovyBeanDefinitionSource source) used both XML and Groovy readers, but since its return value seems to be not used I was able to remove this cross dependency. I have validated via spring-graalvm-native that the code removal is still effective. Please let me know if I missed something.

@wilkinsona wilkinsona changed the title Disable XML reader when spring.xml.ignore is true Disable XML bean definition loading when spring.xml.ignore is true Jun 25, 2020
@wilkinsona wilkinsona added theme: performance Issues related to general performance type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 25, 2020
@wilkinsona wilkinsona added this to the 2.4.x milestone Jun 25, 2020
wilkinsona pushed a commit that referenced this pull request Jun 25, 2020
This commit allows to set the XmlBeanDefinitionReader field from
BeanDefinitionLoader to null in a way that allows the GraalVM native
compiler to remove it from the native image when the spring.xml.ignore
flag introduced by spring-projects/spring-framework#25151
is set to true.

The purpose of this change is to allow smaller footprint on native
images without requiring to use GraalVM native substitutions
which are unmaintainable by nature and also to increase the consistency
between JVM and native images.

In order to effective, this optimization requires BeanDefinitionLoader
class to be initialized at build time.

See gh-22093
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.4.0-M1 Jun 25, 2020
sdeleuze added a commit to sdeleuze/spring-native that referenced this pull request Jun 25, 2020
Thanks to spring-projects/spring-boot#22093 which brings support of
spring.xml.ignore flag natively to Spring Boot.

See spring-atticgh-138
dsyer pushed a commit to scratches/spring-graalvm-native that referenced this pull request Sep 23, 2020
Thanks to spring-projects/spring-boot#22093 which brings support of
spring.xml.ignore flag natively to Spring Boot.

See spring-atticgh-138
dsyer pushed a commit to scratches/spring-graalvm-native that referenced this pull request Sep 23, 2020
Thanks to spring-projects/spring-boot#22093 which brings support of
spring.xml.ignore flag natively to Spring Boot.

See spring-atticgh-138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: performance Issues related to general performance type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants