Skip to content

Commit 22fcf72

Browse files
committed
Issue jetty#11040 Register custom URI scheme in PathResource when necessary
1 parent bd342ac commit 22fcf72

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/PathResource.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ public class PathResource extends Resource
4040
{
4141
private static final Logger LOG = LoggerFactory.getLogger(PathResource.class);
4242

43-
public static Index<String> SUPPORTED_SCHEMES = new Index.Builder<String>()
44-
.caseSensitive(false)
45-
.with("file")
46-
.with("jrt")
47-
.build();
43+
public static Index<String> SUPPORTED_SCHEMES = initSupportedSchemes(null);
4844

4945
// The path object represented by this instance
5046
private final Path path;
@@ -541,4 +537,18 @@ public String toString()
541537
{
542538
return this.uri.toASCIIString();
543539
}
540+
541+
static Index<String> initSupportedSchemes(String extraScheme)
542+
{
543+
Index.Builder<String> builder = new Index.Builder<String>()
544+
.caseSensitive(false)
545+
.with("file")
546+
.with("jrt");
547+
if (extraScheme != null)
548+
{
549+
builder = builder.with(extraScheme);
550+
}
551+
552+
return builder.build();
553+
}
544554
}

jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/ResourceFactoryInternals.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class ResourceFactoryInternals
7676
resourceFactory = url.toString().contains("!/") ? mountedPathResourceFactory : pathResourceFactory;
7777
}
7878

79-
RESOURCE_FACTORIES.put(url.getProtocol(), resourceFactory);
79+
String protocol = url.getProtocol();
80+
PathResource.SUPPORTED_SCHEMES = PathResource.initSupportedSchemes(protocol);
81+
RESOURCE_FACTORIES.put(protocol, resourceFactory);
8082
}
8183
}
8284

0 commit comments

Comments
 (0)