Copilot commented on code in PR #15824:
URL: https://github.com/apache/grails-core/pull/15824#discussion_r3523623388
##########
grails-spring/src/main/groovy/grails/spring/BeanBuilder.java:
##########
@@ -234,11 +218,11 @@ public void xmlns(Map<String, String> definition) {
Assert.notNull(uri, "Namespace definition cannot supply a null
URI");
- final NamespaceHandler namespaceHandler =
namespaceHandlerResolver.resolve(uri);
+ final NamespaceHandler namespaceHandler =
getXmlSupport().resolveNamespaceHandler(uri);
if (namespaceHandler == null) {
throw new BeanDefinitionParsingException(
new Problem("No namespace handler found for URI: " + uri,
- new Location(readerContext.getResource())));
+ new
Location(getXmlSupport().getReaderContext(beanBuildResource).getResource())));
Review Comment:
In the error path for an unknown XML namespace, this code calls
getXmlSupport().getReaderContext(...) just to obtain a Resource for Location.
Creating the XmlReaderContext will also lazily create the
XmlBeanDefinitionReader, which in turn forces
springConfig.getUnrefreshedApplicationContext() initialization. That adds
unnecessary work in an exception path and can mask the intended "No namespace
handler found" error if context initialization fails.
You can use the already-available beanBuildResource directly when
constructing Location to avoid initializing XML reader/context infrastructure
for this error message.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]