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

JdbiUtil: use concurrent data structure to store static state #2341

Merged
merged 1 commit into from May 4, 2023

Conversation

stevenschlansker
Copy link
Member

Fixes #2336

@stevenschlansker stevenschlansker requested a review from a team May 2, 2023 21:20

import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.core.internal.UtilityClassException;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
Copy link
Member Author

Choose a reason for hiding this comment

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

This class is deprecated for removal.

import org.springframework.transaction.support.TransactionSynchronizationManager;

/**
* Utility for working with Jdbi and Spring transaction bound resources
*/
public class JdbiUtil {
private static final Set<Handle> TRANSACTIONAL_HANDLES = new HashSet<>();
private static final Set<Handle> TRANSACTIONAL_HANDLES = Collections.newSetFromMap(new ConcurrentHashMap<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

I am cool with this, but we did use CopyOnWriteSet in other places where concurrency was required.

RELEASE_NOTES.md Outdated
@@ -1,4 +1,5 @@
# Unreleased
- spring5 JdbiUtil: fix thread safety
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a reference to the issue that this addresses

@stevenschlansker
Copy link
Member Author

stevenschlansker commented May 4, 2023 via email

@stevenschlansker stevenschlansker merged commit f371899 into master May 4, 2023
35 checks passed
@stevenschlansker stevenschlansker deleted the spring-chm branch May 4, 2023 16:21
@sonarcloud
Copy link

sonarcloud bot commented May 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

jdbi3-spring plugin JdbiUtil.TRANSACTIONAL_HANDLES should be made from a concurrent hash map
2 participants