Honor ProtocolResolvers in GenericApplicationContext

When the ProtocolResolver SPI was introduced in Spring Framework 4.3,
support for protocol resolvers was added in DefaultResourceLoader's
getResource() implementation; however, GenericApplicationContext's
overridden getResource() implementation was not updated accordingly.

Prior to this commit, if a GenericApplicationContext was configured
with a custom ResourceLoader, registered protocol resolvers were
ignored.

This commit ensures that protocol resolvers are honored in
GenericApplicationContext even if a custom ResourceLoader is used.

Closes gh-28703
This commit is contained in:
Sam Brannen
2022-06-27 18:00:29 +02:00
parent a970516080
commit 9868c28c73
3 changed files with 78 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,8 @@ import org.springframework.util.StringUtils;
/**
* Default implementation of the {@link ResourceLoader} interface.
* Used by {@link ResourceEditor}, and serves as base class for
*
* <p>Used by {@link ResourceEditor}, and serves as base class for
* {@link org.springframework.context.support.AbstractApplicationContext}.
* Can also be used standalone.
*
@@ -114,6 +115,7 @@ public class DefaultResourceLoader implements ResourceLoader {
* Return the collection of currently registered protocol resolvers,
* allowing for introspection as well as modification.
* @since 4.3
* @see #addProtocolResolver(ProtocolResolver)
*/
public Collection<ProtocolResolver> getProtocolResolvers() {
return this.protocolResolvers;