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

[improve][client] Replace NameUtil#generateRandomName with RandomStringUtils#randomAlphanumeric #23645

Conversation

geniusjoe
Copy link
Contributor

Main Issue: apache/pulsar-client-go#1297
Relative #23577

Motivation

According to #23577 (comment), currently NameUtil#generateRandomName() is only used in just few cases. Maybe we could use org.apache.commons.lang3.RandomStringUtils#randomAlphanumeric(int) to replace this class for better readability and code structure.

Modifications

Based on #23577 (comment) intention:
Remove NameUtil completely and use Commons Lang3's org.apache.commons.lang3.RandomStringUtils#randomAlphanumeric(int) method with the parameter 5 to create a random string of 5 characters.

Verifying this change

This change added tests and can be verified as follows:
org.apache.pulsar.client.impl.ConsumerImplTest#testAutoGenerateConsumerName

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
    Default consumer name generating rule will be changed from [a-f0-9]{5} to [a-zA-Z0-9]{5}.
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

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

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 27, 2024
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.36%. Comparing base (bbc6224) to head (670989f).
Report is 767 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23645      +/-   ##
============================================
+ Coverage     73.57%   74.36%   +0.78%     
- Complexity    32624    34999    +2375     
============================================
  Files          1877     1943      +66     
  Lines        139502   147201    +7699     
  Branches      15299    16240     +941     
============================================
+ Hits         102638   109462    +6824     
- Misses        28908    29309     +401     
- Partials       7956     8430     +474     
Flag Coverage Δ
inttests 27.50% <80.00%> (+2.91%) ⬆️
systests 24.30% <60.00%> (-0.02%) ⬇️
unittests 73.74% <100.00%> (+0.90%) ⬆️

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

Files with missing lines Coverage Δ
...va/org/apache/pulsar/client/impl/ConsumerBase.java 75.68% <100.00%> (+1.55%) ⬆️
...va/org/apache/pulsar/client/impl/ConsumerImpl.java 80.27% <100.00%> (+2.70%) ⬆️
...he/pulsar/client/impl/MultiTopicsConsumerImpl.java 77.87% <100.00%> (+0.15%) ⬆️

... and 665 files with indirect coverage changes

@Technoboy- Technoboy- added this to the 4.1.0 milestone Nov 29, 2024
@Technoboy- Technoboy- merged commit 32b3ccf into apache:master Nov 29, 2024
54 checks passed
lhotari pushed a commit that referenced this pull request Nov 29, 2024
…ngUtils#randomAlphanumeric (#23645)

(cherry picked from commit 32b3ccf)
lhotari pushed a commit that referenced this pull request Nov 29, 2024
…ngUtils#randomAlphanumeric (#23645)

(cherry picked from commit 32b3ccf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants