-
Notifications
You must be signed in to change notification settings - Fork 1.2k
DATAREDIS-1034 - Fix dataraces in RedisTemplate. #479
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
Conversation
Previously it was possible in multi-threaded environment to: * get a `null` from `opsFor*` methods in RedisTemplate. * fail with a `NullPointerException` when working with a not-`null` reference returned from `RedisTemplate.opsFor*` methods. Introduced changes initialize the fields eagerly to avoid a datarace when accessing them and add a `final` modifier to the `AbstractOperations#template` field. Please note that these changes still require a client to publish a reference to RedisTemplate safely (getting a reference from an `ApplicationContext` is fine). Also note that escaping a reference to `this` in `RedisTemplate` initializer should also be ok, because putting a bean into `ApplicationContext` happens-before its subsequent retrieval. Original pull request: #479.
Previously it was possible in multi-threaded environment to: * get a `null` from `opsFor*` methods in RedisTemplate. * fail with a `NullPointerException` when working with a not-`null` reference returned from `RedisTemplate.opsFor*` methods. Introduced changes initialize the fields eagerly to avoid visibility issues when accessing them and add a `final` modifier to the `AbstractOperations#template` field. Original pull request: #479.
Pre-allocate operations objects for immutable serializationContext in ReactiveRedisTemplate. Original pull request: #479.
Previously it was possible in multi-threaded environment to: * get a `null` from `opsFor*` methods in RedisTemplate. * fail with a `NullPointerException` when working with a not-`null` reference returned from `RedisTemplate.opsFor*` methods. Introduced changes initialize the fields eagerly to avoid visibility issues when accessing them and add a `final` modifier to the `AbstractOperations#template` field. Original pull request: #479.
Pre-allocate operations objects for immutable serializationContext in ReactiveRedisTemplate. Original pull request: #479.
Thanks a lot. That's merged, backported, and polished now. |
Thanks for merging, Mark |
These changes appear to have broken Spring Session build after picking them up via the latest Spring Data Redis snapshot:
Since |
@vpavic is there a specific reason why |
SLF4J is required for Spring Data (as a general rule of thumb). We migrated some projects away from SLF4J towards JCL, maybe we should follow that path consistently. |
Thanks for the feedback @christophstrobl and @mp911de. Ever since |
It makes sense to revisit our logging dependencies with the next release train. I'm not sure what the rationale was to use SLF4J. |
With next release train you're not referring to Because we'll need something for |
Sorry, I wasn't precise enough. I meant For now, please include SLF4J. It was a lucky coincidence that excluding SLF4J worked until now. |
Previously it was possible in multi-threaded environment to:
null
fromopsFor*
methods in RedisTemplate.NullPointerException
when working with a not-null
reference returned fromRedisTemplate.opsFor*
methods.Introduced changes initialize the fields eagerly to avoid a datarace when accessing them and add a
final
modifier to theAbstractOperations#template
field.Please note that these changes still require a client to publish a reference to RedisTemplate safely (getting a reference from an
ApplicationContext
is fine).Also note that escaping a reference to
this
inRedisTemplate
initializer should also be ok, because putting a bean intoApplicationContext
happens-before its subsequent retrieval.Original pull request: #???.