You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/01 07:40:53 UTC

[GitHub] [shardingsphere] sandynz commented on a diff in pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()

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


##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -57,7 +62,25 @@ public ShardingSphereDriverURL(final String url) {
     @SneakyThrows(IOException.class)
     public byte[] toConfigurationBytes() {
         try (InputStream stream = inClasspath ? ShardingSphereDriverURL.class.getResourceAsStream("/" + file) : Files.newInputStream(new File(file).toPath())) {
-            byte[] result = new byte[null == stream ? 0 : stream.available()];
+            LineProcessor<byte[]> lineProcessor = new LineProcessor<byte[]>() {
+                
+                private final StringBuilder builder = new StringBuilder();
+                

Review Comment:
   Could we simplify it with `Files.readAllLines`? Refer to `DataSourcePersistServiceTest.readDataSourceYaml` for more details.
   
   And guava dependency might be removed later.



##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -57,7 +62,25 @@ public ShardingSphereDriverURL(final String url) {
     @SneakyThrows(IOException.class)
     public byte[] toConfigurationBytes() {
         try (InputStream stream = inClasspath ? ShardingSphereDriverURL.class.getResourceAsStream("/" + file) : Files.newInputStream(new File(file).toPath())) {
-            byte[] result = new byte[null == stream ? 0 : stream.available()];
+            LineProcessor<byte[]> lineProcessor = new LineProcessor<byte[]>() {
+                
+                private final StringBuilder builder = new StringBuilder();
+                
+                @Override
+                public boolean processLine(final String line) {
+                    if (line.startsWith("#") || 0 == line.length()) {
+                        return true;
+                    }

Review Comment:
   Looks empty line is removed by `0 == line.length()`. It's better to keep empty line, since it's the content of configuration file.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org