Skip to content

Cache in RedisUtils is not thread safe #2884

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

Closed
pete-woods opened this issue Apr 4, 2019 · 2 comments
Closed

Cache in RedisUtils is not thread safe #2884

pete-woods opened this issue Apr 4, 2019 · 2 comments
Assignees
Milestone

Comments

@pete-woods
Copy link

pete-woods commented Apr 4, 2019

Affects Version(s): master


The LinkedHashMap in https://github.com/spring-projects/spring-integration/blob/master/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisUtils.java is accessed from multiple threads when using RedisLockRegistry, resulting in concurrency exceptions. I worked around the problem in my app by overriding the implementation there with one using Guava's cache. Spring integration doesn't have a dependency on Caffeine or Guava, or I'd have submitted a simple patch.

@garyrussell
Copy link
Contributor

Why do we call this on every remove call anyway? We should just cache the result in the store and registry during intiialization since the RedisTemplate is final in both cases.

@garyrussell garyrussell added this to the 5.1.5 milestone Apr 5, 2019
@garyrussell garyrussell self-assigned this Apr 5, 2019
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Apr 5, 2019
Fixes spring-projects#2884

- synchronize the map
- only call once per component
garyrussell added a commit to garyrussell/spring-integration that referenced this issue Apr 5, 2019
Fixes spring-projects#2884

- synchronize the map
- only call once per component
artembilan pushed a commit that referenced this issue Apr 5, 2019
Fixes #2884

- synchronize the map
- only call once per component
artembilan pushed a commit that referenced this issue Apr 5, 2019
Fixes #2884

- synchronize the map
- only call once per component

# Conflicts:
#	spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java
@pete-woods
Copy link
Author

Thanks for the quick fix!

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

No branches or pull requests

2 participants