zhfeng commented on code in PR #22677:
URL: https://github.com/apache/shardingsphere/pull/22677#discussion_r1040439971
##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -72,4 +72,30 @@ public byte[] toConfigurationBytes() {
return builder.toString().getBytes(StandardCharsets.UTF_8);
}
}
+
+ private InputStream getResourceAsStream(final String resource) throws
IOException {
+ ClassLoader[] classLoader = new ClassLoader[]{
+ Thread.currentThread().getContextClassLoader(),
+ getClass().getClassLoader(),
+ ClassLoader.getSystemClassLoader(),
+ };
+
+ for (ClassLoader cl : classLoader) {
+ if (null != cl) {
+
+ // try to find the resource as passed
+ InputStream returnValue = cl.getResourceAsStream(resource);
+
+ // now, some class loaders want this leading "/", so we'll add
it and try again if we didn't find the resource
+ if (null == returnValue) {
+ returnValue = cl.getResourceAsStream("/" + resource);
+ }
Review Comment:
sorry, I think it is not correctly. It looks like when using
`getClass().getClassLoader()`, it always uses the relative path. But if there
is a custom classloader, it could need the leading of `/`. Perhaps in case of
some application containers, such as `Tomcat`
--
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]