jamesfredley commented on code in PR #16041:
URL: https://github.com/apache/grails-core/pull/16041#discussion_r3630431956
##########
grails-shell-cli/src/main/groovy/org/grails/cli/boot/SpringApplicationWebApplicationInitializer.java:
##########
@@ -51,15 +51,28 @@ public void onStartup(ServletContext servletContext) throws
ServletException {
catch (IOException ex) {
throw new IllegalStateException(ex);
}
+ // This initializer only applies to CLI-packaged WARs produced by the
Grails shell 'war'
+ // command, which records the application source classes in the WAR
manifest via the
+ // 'Spring-Application-Source-Classes' entry. When that entry is
absent (for example a
+ // standard 'bootWar' archive deployed to an external servlet
container such as Tomcat),
+ // this initializer is not applicable and must stay inert so it does
not interfere with
+ // the application's own SpringBootServletInitializer.
+ // See https://github.com/apache/grails-core/issues/15377
+ if (this.sources == null || this.sources.length == 0) {
+ return;
+ }
super.onStartup(servletContext);
}
private String[] getSources(ServletContext servletContext) throws
IOException {
Manifest manifest = getManifest(servletContext);
if (manifest == null) {
- throw new IllegalStateException("Unable to read manifest");
+ return null;
}
String sources = manifest.getMainAttributes().getValue(SOURCE_ENTRY);
+ if (sources == null || sources.isBlank()) {
+ return null;
+ }
return sources.split(",");
Review Comment:
Declining this one as out of scope for the fix. The
`Spring-Application-Source-Classes` manifest value is written by
`ArchiveCommand.commaDelimitedClassNames(...)`, which joins fully-qualified
class names with a bare `,` and no surrounding whitespace, so the comma+space
token scenario does not arise for CLI-packaged WARs (the only path that reaches
`configure()`/`Class.forName`). The `sources.split(",")` line is also
pre-existing and unrelated to this NPE backport, so trimming/filtering tokens
would be a separate change beyond the scope of #15377.
--
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]