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

IllegalArgumentException on org.springframework.web.servlet.resource.ResourceHttpRequestHandler v6.2.0-RC3 if resource doesn't end with slash #42929

Closed
milazzo-g opened this issue Oct 29, 2024 · 1 comment
Labels
for: external-project For an external project and not something we can fix

Comments

@milazzo-g
Copy link

During context loading the ResourceHttpRequestHandler class scans all possible paths and if these do not end with "/" an IllegalArgumentException type exception is thrown with message "Resource location does not end with slash: …" (see ResourceHttpRequestHandler@282 the call to ResourceHttpRequestHandler::assertLocationPath) this cause several issue with various jar included (in our case camunda-webapp-webjar 7.22.0 - included by camunda-bpm-spring-boot-starter-root 7.22.0).

The path provided by the library is "classpath:/META-INF/resources/webjars/camunda" which as you can see does not contain the final "/". makes it unusable with spring-boot 6.2.0-RC3.

We temporary fixed creating a copy of org.springframework.web.servlet.resource.ResourceHttpRequestHandler in our src folder and modifying starting from line 282 from:

ResourceHandlerUtils.assertLocationPath(location);

to:

try {
 ResourceHandlerUtils.assertLocationPath(location);
} catch (Exception e) {
 if (org.apache.commons.lang3.StringUtils.containsIgnoreCase(e.getMessage(), "resource location does not end with slash")){
  location += "/";
 }else {
  throw e;
 }
}

this solved the issue. Could you please fix it in a next minor?

KR.

Giuseppe.

1_ResourceHttpRequestHandler
2_ResourceHandlerUtils
STACKTRACE.txt

@philwebb
Copy link
Member

The code in question is part of Spring Framework. I've duplicated your issue to spring-projects/spring-framework#33815

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
@philwebb philwebb added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants