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 NullPointerException hazard in StringUtils.join(..) method #3983

Merged
merged 1 commit into from
Sep 14, 2021

Conversation

WillardHu
Copy link
Contributor

@WillardHu WillardHu commented Sep 14, 2021

Signed-off-by: WillardHu [email protected]

What's the purpose of this PR

When the collection is null, a NullPointerException is thrown here. Otherwise iterator == null is always false.

Which issue(s) this PR fixes:

Fixes #

Brief changelog

fix NullPointerException hazard in StringUtils.join(..) method.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2021

Codecov Report

Merging #3983 (9e30ebe) into master (0b5d227) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3983   +/-   ##
=========================================
  Coverage     50.76%   50.76%           
+ Complexity     2468     2462    -6     
=========================================
  Files           475      475           
  Lines         14600    14580   -20     
  Branches       1521     1514    -7     
=========================================
- Hits           7412     7402   -10     
+ Misses         6661     6651   -10     
  Partials        527      527           
Impacted Files Coverage Δ
...ctrip/framework/apollo/core/utils/StringUtils.java 82.35% <ø> (+17.53%) ⬆️
...rk/apollo/spring/property/SpringValueRegistry.java 83.78% <0.00%> (-5.41%) ⬇️
.../framework/apollo/spring/property/SpringValue.java 87.71% <0.00%> (-1.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b5d227...9e30ebe. Read the comment docs.

@@ -355,11 +355,11 @@ public String format(T obj) {

public static <T> String join(Collection<T> collection, String separator,
Copy link
Member

Choose a reason for hiding this comment

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

Seems this method is only used in tests, let's just remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed method and changed the commit message to 'delete unused method StringUtils.join(..)'

Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

LGTM, although this is kind of breaking changes in apollo-client, I think these 2 methods are not meant to be used by users, and it's easy to migrate to other string util, I'm OK to remove them, WDYT @nobodyiam

@nobodyiam
Copy link
Member

@kezhenxu94 I agree with you that it's ok to remove these 2 methods

@kezhenxu94 kezhenxu94 merged commit d8b685e into apolloconfig:master Sep 14, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2021
@WillardHu WillardHu deleted the fix/stringutils-join branch September 14, 2021 13:29
@nobodyiam nobodyiam added this to the 1.10.0 milestone Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants