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:04:28 UTC
[GitHub] [shardingsphere] gxxiong opened a new pull request, #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
gxxiong opened a new pull request, #22557:
URL: https://github.com/apache/shardingsphere/pull/22557
Fixes #22445.
Changes proposed in this pull request:
-Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
---
Before committing this PR, I'm sure that I have checked the following options:
- [X] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [X] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [X] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [X] I have added corresponding unit tests for my changes.
--
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
[GitHub] [shardingsphere] sandynz commented on a diff in pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
Posted by GitBox <gi...@apache.org>.
sandynz commented on code in PR #22557:
URL: https://github.com/apache/shardingsphere/pull/22557#discussion_r1036808888
##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -57,7 +61,15 @@ 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()];
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8));
+ StringBuilder builder = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (!line.startsWith("#")) {
+ builder.append(line);
+ }
+ }
+ final byte[] result = builder.toString().getBytes(StandardCharsets.UTF_8);
Objects.requireNonNull(stream, String.format("Can not find configuration file `%s`.", file)).read(result);
Review Comment:
Seems `Objects.requireNonNull` should be put after `try-resource` and before real reading
##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -17,12 +17,16 @@
package org.apache.shardingsphere.driver.jdbc.core.driver;
+import com.google.common.base.Charsets;
Review Comment:
Could `com.google.common.base.Charsets` be replaced to `StandardCharsets`?
--
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
[GitHub] [shardingsphere] sandynz commented on a diff in pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [shardingsphere] gxxiong commented on a diff in pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
Posted by GitBox <gi...@apache.org>.
gxxiong commented on code in PR #22557:
URL: https://github.com/apache/shardingsphere/pull/22557#discussion_r1036803081
##########
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:
File reading will have problems when packaged into jar
--
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
[GitHub] [shardingsphere] codecov-commenter commented on pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #22557:
URL: https://github.com/apache/shardingsphere/pull/22557#issuecomment-1333333643
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/22557?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#22557](https://codecov.io/gh/apache/shardingsphere/pull/22557?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0c363ac) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3d565f9c0c64bf357ff30118c52a3faae3d9b5ab?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3d565f9) will **decrease** coverage by `0.34%`.
> The diff coverage is `66.66%`.
```diff
@@ Coverage Diff @@
## master #22557 +/- ##
============================================
- Coverage 50.97% 50.63% -0.35%
+ Complexity 2520 2470 -50
============================================
Files 4190 4115 -75
Lines 58303 57571 -732
Branches 9917 9821 -96
============================================
- Hits 29721 29150 -571
+ Misses 26057 25923 -134
+ Partials 2525 2498 -27
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/22557?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...t/command/admin/MySQLComResetConnectionPacket.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGItcHJvdG9jb2wvbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RiL3Byb3RvY29sL215c3FsL3BhY2tldC9jb21tYW5kL2FkbWluL015U1FMQ29tUmVzZXRDb25uZWN0aW9uUGFja2V0LmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...scenario/consistencycheck/ConsistencyCheckJob.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL0NvbnNpc3RlbmN5Q2hlY2tKb2IuamF2YQ==) | `0.00% <ø> (ø)` | |
| [...enario/consistencycheck/ConsistencyCheckJobId.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL0NvbnNpc3RlbmN5Q2hlY2tKb2JJZC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...stencycheck/api/ConsistencyCheckJobAPIFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL2FwaS9Db25zaXN0ZW5jeUNoZWNrSm9iQVBJRmFjdG9yeS5qYXZh) | `0.00% <ø> (ø)` | |
| [...encycheck/api/impl/ConsistencyCheckJobAPIImpl.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL2FwaS9pbXBsL0NvbnNpc3RlbmN5Q2hlY2tKb2JBUElJbXBsLmphdmE=) | `0.00% <ø> (ø)` | |
| [...ycheck/context/ConsistencyCheckJobItemContext.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL2NvbnRleHQvQ29uc2lzdGVuY3lDaGVja0pvYkl0ZW1Db250ZXh0LmphdmE=) | `0.00% <ø> (ø)` | |
| [...sistencyCheckChangedJobConfigurationProcessor.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL21ldGFkYXRhL3Byb2Nlc3Nvci9Db25zaXN0ZW5jeUNoZWNrQ2hhbmdlZEpvYkNvbmZpZ3VyYXRpb25Qcm9jZXNzb3IuamF2YQ==) | `0.00% <ø> (ø)` | |
| [...istencycheck/task/ConsistencyCheckTasksRunner.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL3Rhc2svQ29uc2lzdGVuY3lDaGVja1Rhc2tzUnVubmVyLmphdmE=) | `0.00% <ø> (ø)` | |
| [...onsistencycheck/util/ConsistencyCheckSequence.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vY29uc2lzdGVuY3ljaGVjay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9zY2VuYXJpby9jb25zaXN0ZW5jeWNoZWNrL3V0aWwvQ29uc2lzdGVuY3lDaGVja1NlcXVlbmNlLmphdmE=) | `0.00% <ø> (ø)` | |
| [...data/pipeline/scenario/migration/MigrationJob.java](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvc2NlbmFyaW8vbWlncmF0aW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9kYXRhL3BpcGVsaW5lL3NjZW5hcmlvL21pZ3JhdGlvbi9NaWdyYXRpb25Kb2IuamF2YQ==) | `0.00% <ø> (ø)` | |
| ... and [28 more](https://codecov.io/gh/apache/shardingsphere/pull/22557/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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
[GitHub] [shardingsphere] sandynz commented on a diff in pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
Posted by GitBox <gi...@apache.org>.
sandynz commented on code in PR #22557:
URL: https://github.com/apache/shardingsphere/pull/22557#discussion_r1036828486
##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -57,8 +60,16 @@ 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()];
- Objects.requireNonNull(stream, String.format("Can not find configuration file `%s`.", file)).read(result);
+ Objects.requireNonNull(stream, String.format("Can not find configuration file `%s`.", file)).read();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
+ StringBuilder builder = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (!line.startsWith("#")) {
+ builder.append(line);
+ }
+ }
+ final byte[] result = builder.toString().getBytes(StandardCharsets.UTF_8);
return result;
Review Comment:
The last two lines could be merged to one line for less code
##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/driver/ShardingSphereDriverURL.java:
##########
@@ -57,8 +60,16 @@ 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()];
- Objects.requireNonNull(stream, String.format("Can not find configuration file `%s`.", file)).read(result);
+ Objects.requireNonNull(stream, String.format("Can not find configuration file `%s`.", file)).read();
Review Comment:
Seems `...stream.read();` could be removed, data is already read by BufferedReader
--
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
[GitHub] [shardingsphere] sandynz merged pull request #22557: Ignore license header for ShardingSphereDriverURL.toConfigurationBytes()
Posted by GitBox <gi...@apache.org>.
sandynz merged PR #22557:
URL: https://github.com/apache/shardingsphere/pull/22557
--
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