sandynz commented on code in PR #22677:
URL: https://github.com/apache/shardingsphere/pull/22677#discussion_r1040377447


##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -72,4 +72,22 @@ public byte[] toConfigurationBytes() {
             return builder.toString().getBytes(StandardCharsets.UTF_8);
         }
     }
+    
+    private InputStream getResourceAsStream(final String resource) throws 
IOException {
+        ClassLoader[] classLoaders = new ClassLoader[]{
+                Thread.currentThread().getContextClassLoader(), 
getClass().getClassLoader(), ClassLoader.getSystemClassLoader(),
+        };
+        for (ClassLoader each : classLoaders) {
+            if (null != each) {
+                InputStream result = each.getResourceAsStream(resource);
+                if (null == result) {
+                    result = each.getResourceAsStream("/" + resource);
+                }

Review Comment:
   1, Could we remove the last `,` after `ClassLoader.getSystemClassLoader()`?
   
   2, And did you try to run `mvn spotless:apply` in this module? Seems it 
might change the code formatting.
   



##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -72,4 +72,22 @@ public byte[] toConfigurationBytes() {
             return builder.toString().getBytes(StandardCharsets.UTF_8);
         }
     }
+    
+    private InputStream getResourceAsStream(final String resource) throws 
IOException {
+        ClassLoader[] classLoaders = new ClassLoader[]{
+                Thread.currentThread().getContextClassLoader(), 
getClass().getClassLoader(), ClassLoader.getSystemClassLoader(),
+        };
+        for (ClassLoader each : classLoaders) {
+            if (null != each) {
+                InputStream result = each.getResourceAsStream(resource);
+                if (null == result) {
+                    result = each.getResourceAsStream("/" + resource);
+                }

Review Comment:
   Could we bind resource path with class loader? Maybe it's more efficient and 
readable.
   e.g. `TCCL` just use `resource`, `getClass().getClassLoader()` just use `"/" 
+ resource`



-- 
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]

Reply via email to