Skip to content

GenericApplicationContext does not honor ProtocolResolver when a resource loader is set via setResourceLoader() #28703

Closed
@arteymix

Description

@arteymix

I'm trying to intercept certain URL patterns to resolve into the correct UrlResource, but the application context does not honour custom protocol resolvers.

In pseudocode:

GenericApplicationContext applicationContext = new GenericApplicationContext();
applicationContext.setResourceLoader(someResourceLoader);
applicationContext.addProtocolResolver(new CustomUrlResolver());
applicationContext.getResource("http://some.custom.url/"); // never resolved via CustomUrlResolver

The CustomUrlResolver resolver is never invoked because someResourceLoader takes precedence in getResource. Unfortunately, there's no way to work around this issue by adding a delegating resource loader, since there's no accessor for the resource loader.

I believe that the setResourceLoader(...) call is done somewhere in Spring Boot.

I had to do setResourceLoader(null). This is likely going to break things.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions