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 NPE in SimpleConnectionPool.restore() and optimize borrow() with computeIfAbsent() #1938

Merged
merged 1 commit into from Oct 31, 2023

Conversation

miklish
Copy link
Collaborator

@miklish miklish commented Oct 30, 2023

Issue: #1898

We can use the computeIfAbsent method of ConcurrentHashMap to add a new SimpleURIConnectionPool to a SimpleConnectionPool.

computeIfAbsent uses more efficient lock on the hashmap bucket for they uri key, rather than requiring synchronization on the entire ConcurrentHashMap.

Also we avoid creating an then discarding objects if the method is called after a value has already been put, since the lamda argument of computeIfAbsent is only executed if a value does not already exist.

Additionally, there is a missing NP check in the restore method.

@stevehu stevehu merged commit 52548c5 into 1.6.x Oct 31, 2023
@stevehu stevehu deleted the issue_1898 branch October 31, 2023 12:53
stevehu pushed a commit that referenced this pull request Jan 25, 2024
…ow() with use of computeIfAbsent() (#1938)

Co-authored-by: Michael Christoff <mike.christoff@cibc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants