Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][client] Fix the Windows absolute path not recognized in auth param string #18403

Merged

Conversation

BewareMyPower
Copy link
Contributor

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

String[] kv = p.split(":");
if (kv.length == 2) {
authParams.put(kv[0], kv[1]);
}

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

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: BewareMyPower#6

…ram string

### 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".
@BewareMyPower BewareMyPower added type/bug The PR fixed a bug or issue reported a bug area/client labels Nov 10, 2022
@BewareMyPower BewareMyPower self-assigned this Nov 10, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 10, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2022

Codecov Report

Merging #18403 (496cc81) into master (aeb4503) will increase coverage by 15.42%.
The diff coverage is 62.50%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #18403       +/-   ##
=============================================
+ Coverage     31.39%   46.82%   +15.42%     
- Complexity     6651    10358     +3707     
=============================================
  Files           697      697               
  Lines         68015    68026       +11     
  Branches       7285     7285               
=============================================
+ Hits          21353    31850    +10497     
+ Misses        43667    32611    -11056     
- Partials       2995     3565      +570     
Flag Coverage Δ
unittests 46.82% <62.50%> (+15.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ersistentStreamingDispatcherMultipleConsumers.java 0.00% <0.00%> (ø)
...he/pulsar/client/impl/MultiTopicsConsumerImpl.java 22.26% <0.00%> (ø)
...ersistentStickyKeyDispatcherMultipleConsumers.java 58.91% <50.00%> (+20.44%) ⬆️
...sistent/PersistentDispatcherMultipleConsumers.java 51.55% <75.00%> (+12.32%) ⬆️
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 53.95% <100.00%> (+0.10%) ⬆️
...pulsar/broker/admin/impl/PersistentTopicsBase.java 58.92% <100.00%> (+43.15%) ⬆️
.../apache/pulsar/client/impl/AuthenticationUtil.java 59.37% <100.00%> (+4.20%) ⬆️
...lsar/client/impl/conf/ClientConfigurationData.java 96.66% <100.00%> (+0.11%) ⬆️
...java/org/apache/pulsar/proxy/stats/TopicStats.java 58.82% <0.00%> (-41.18%) ⬇️
...apache/pulsar/client/impl/AutoClusterFailover.java 73.33% <0.00%> (-2.78%) ⬇️
... and 167 more

@nodece
Copy link
Member

nodece commented Nov 15, 2022

@BewareMyPower Please fix failed tests.

@Technoboy- Technoboy- added this to the 2.12.0 milestone Nov 19, 2022
@nodece nodece merged commit 177b96a into apache:master Nov 21, 2022
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-win-resource-path branch November 24, 2022 07:02
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Dec 9, 2022
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Jan 10, 2023
michaeljmarshall added a commit that referenced this pull request Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client cherry-picked/branch-2.11 doc-not-needed Your PR changes do not impact docs release/2.11.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants