You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/10 06:20:13 UTC

[GitHub] [pulsar] BewareMyPower opened a new pull request, #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

BewareMyPower opened a new pull request, #18403:
URL: https://github.com/apache/pulsar/pull/18403

   ### Motivation
   
   When the auth param string contains a key-value pair whose value is a Windows absolute path like:
   
   ```
   keyStorePath:C:\path\to\client.keystore.jks
   ```
   
   The path will be discarded. See
   https://github.com/apache/pulsar/blob/06506761aff0eae4acbffa68c3431d2c96affe29/pulsar-client/src/main/java/org/apache/pulsar/client/impl/AuthenticationUtil.java#L46-L49
   
   ### Modifications
   
   When a key-value string can be split into more than 2 tokens by ':', treat the 1st token as the key, and the following part as the value.
   
   In addition, fix some tests cannot run on Windows because of the `URL#getPath` might return something like "/C:/path/to/file". Add a `ResourceUtils` class to convert it to the absolute path like "C:\path\to\file".
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/BewareMyPower/pulsar/pull/6


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] nodece merged pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
nodece merged PR #18403:
URL: https://github.com/apache/pulsar/pull/18403


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] codecov-commenter commented on pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#issuecomment-1313786904

   # [Codecov](https://codecov.io/gh/apache/pulsar/pull/18403?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 [#18403](https://codecov.io/gh/apache/pulsar/pull/18403?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (78e7633) into [master](https://codecov.io/gh/apache/pulsar/commit/fdf86d3b4e66e25936c2e2143bb5809b079ebc0d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fdf86d3) will **increase** coverage by `4.38%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/pulsar/pull/18403/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/pulsar/pull/18403?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18403      +/-   ##
   ============================================
   + Coverage     45.67%   50.05%   +4.38%     
   + Complexity    10075     7222    -2853     
   ============================================
     Files           693      409     -284     
     Lines         67940    44090   -23850     
     Branches       7273     4517    -2756     
   ============================================
   - Hits          31030    22070    -8960     
   + Misses        33333    19589   -13744     
   + Partials       3577     2431    -1146     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `50.05% <0.00%> (+4.38%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/18403?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...adbalance/extensions/channel/ServiceUnitState.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9leHRlbnNpb25zL2NoYW5uZWwvU2VydmljZVVuaXRTdGF0ZS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...lance/extensions/channel/ServiceUnitStateData.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9leHRlbnNpb25zL2NoYW5uZWwvU2VydmljZVVuaXRTdGF0ZURhdGEuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ar/broker/loadbalance/extensions/models/Split.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9leHRlbnNpb25zL21vZGVscy9TcGxpdC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...r/broker/loadbalance/extensions/models/Unload.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9leHRlbnNpb25zL21vZGVscy9VbmxvYWQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...sar/broker/stats/metrics/ManagedLedgerMetrics.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zdGF0cy9tZXRyaWNzL01hbmFnZWRMZWRnZXJNZXRyaWNzLmphdmE=) | `23.88% <0.00%> (-76.12%)` | :arrow_down: |
   | [...rvice/schema/KeyValueSchemaCompatibilityCheck.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3NjaGVtYS9LZXlWYWx1ZVNjaGVtYUNvbXBhdGliaWxpdHlDaGVjay5qYXZh) | `21.62% <0.00%> (-45.95%)` | :arrow_down: |
   | [...java/org/apache/pulsar/proxy/stats/TopicStats.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLXByb3h5L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9wdWxzYXIvcHJveHkvc3RhdHMvVG9waWNTdGF0cy5qYXZh) | `58.82% <0.00%> (-41.18%)` | :arrow_down: |
   | [...ar/broker/loadbalance/impl/BundleSplitterTask.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9pbXBsL0J1bmRsZVNwbGl0dGVyVGFzay5qYXZh) | `60.00% <0.00%> (-20.00%)` | :arrow_down: |
   | [.../org/apache/pulsar/broker/lookup/LookupResult.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb29rdXAvTG9va3VwUmVzdWx0LmphdmE=) | `56.66% <0.00%> (-20.00%)` | :arrow_down: |
   | [...ulsar/broker/namespace/NamespaceEphemeralData.java](https://codecov.io/gh/apache/pulsar/pull/18403/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-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9uYW1lc3BhY2UvTmFtZXNwYWNlRXBoZW1lcmFsRGF0YS5qYXZh) | `68.18% <0.00%> (-18.19%)` | :arrow_down: |
   | ... and [360 more](https://codecov.io/gh/apache/pulsar/pull/18403/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) | |
   


-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#discussion_r1018783291


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AuthenticationUtil.java:
##########
@@ -43,9 +43,10 @@ public static Map<String, String> configureFromPulsar1AuthParamString(String aut
         if (isNotBlank(authParamsString)) {
             String[] params = authParamsString.split(",");
             for (String p : params) {
-                String[] kv = p.split(":");
-                if (kv.length == 2) {
-                    authParams.put(kv[0], kv[1]);
+                // The value could be a file path, which could contain a colon like "C:\\path\\to\\file" on Windows.

Review Comment:
   Added now. I also modified a little to filter empty keys or values. PTAL again.



##########
pulsar-broker/src/test/java/org/apache/pulsar/utils/ResourceUtils.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.utils;
+
+import com.google.common.io.Resources;
+import java.io.File;
+
+public class ResourceUtils {
+
+    public static String getPath(String resourceName) {

Review Comment:
   Renamed now.



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] nodece commented on a diff in pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#discussion_r1021084700


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AuthenticationUtil.java:
##########
@@ -43,9 +43,10 @@ public static Map<String, String> configureFromPulsar1AuthParamString(String aut
         if (isNotBlank(authParamsString)) {
             String[] params = authParamsString.split(",");
             for (String p : params) {
-                String[] kv = p.split(":");
-                if (kv.length == 2) {
-                    authParams.put(kv[0], kv[1]);
+                // The value could be a file path, which could contain a colon like "C:\\path\\to\\file" on Windows.

Review Comment:
   I suggest we should support empty values.



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] nodece commented on a diff in pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#discussion_r1018762838


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AuthenticationUtil.java:
##########
@@ -43,9 +43,10 @@ public static Map<String, String> configureFromPulsar1AuthParamString(String aut
         if (isNotBlank(authParamsString)) {
             String[] params = authParamsString.split(",");
             for (String p : params) {
-                String[] kv = p.split(":");
-                if (kv.length == 2) {
-                    authParams.put(kv[0], kv[1]);
+                // The value could be a file path, which could contain a colon like "C:\\path\\to\\file" on Windows.

Review Comment:
   Could you add a unit test?



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#discussion_r1021033372


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AuthenticationUtil.java:
##########
@@ -43,9 +43,10 @@ public static Map<String, String> configureFromPulsar1AuthParamString(String aut
         if (isNotBlank(authParamsString)) {
             String[] params = authParamsString.split(",");
             for (String p : params) {
-                String[] kv = p.split(":");
-                if (kv.length == 2) {
-                    authParams.put(kv[0], kv[1]);
+                // The value could be a file path, which could contain a colon like "C:\\path\\to\\file" on Windows.

Review Comment:
   @nodece PTAL again



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#discussion_r1021250843


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AuthenticationUtil.java:
##########
@@ -43,9 +43,10 @@ public static Map<String, String> configureFromPulsar1AuthParamString(String aut
         if (isNotBlank(authParamsString)) {
             String[] params = authParamsString.split(",");
             for (String p : params) {
-                String[] kv = p.split(":");
-                if (kv.length == 2) {
-                    authParams.put(kv[0], kv[1]);
+                // The value could be a file path, which could contain a colon like "C:\\path\\to\\file" on Windows.

Review Comment:
   @nodece I agree since the previous implementation also allows empty values. It's addressed now.



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] poorbarcode commented on a diff in pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
poorbarcode commented on code in PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#discussion_r1018711724


##########
pulsar-broker/src/test/java/org/apache/pulsar/utils/ResourceUtils.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.utils;
+
+import com.google.common.io.Resources;
+import java.io.File;
+
+public class ResourceUtils {
+
+    public static String getPath(String resourceName) {

Review Comment:
   Should this method name change to `getAbsolutePath`?



-- 
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: commits-unsubscribe@pulsar.apache.org

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


[GitHub] [pulsar] nodece commented on pull request #18403: [fix][client] Fix the Windows absolute path not recognized in auth param string

Posted by GitBox <gi...@apache.org>.
nodece commented on PR #18403:
URL: https://github.com/apache/pulsar/pull/18403#issuecomment-1314726917

   @BewareMyPower Please fix failed tests.


-- 
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: commits-unsubscribe@pulsar.apache.org

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