Make lazy initialization of static Val.Obj thread-safe#136
Merged
szeiger merged 1 commit intodatabricks:masterfrom Nov 30, 2021
Merged
Make lazy initialization of static Val.Obj thread-safe#136szeiger merged 1 commit intodatabricks:masterfrom
szeiger merged 1 commit intodatabricks:masterfrom
Conversation
iuliand-db
reviewed
Nov 4, 2021
|
|
||
| private[this] def getValue0: util.LinkedHashMap[String, Obj.Member] = { | ||
| if(value0 == null) { | ||
| value0 = new java.util.LinkedHashMap[String, Val.Obj.Member] |
Contributor
There was a problem hiding this comment.
Could you add a comment explaining why we do things in this way, and the multi-threaded guarantee we want to maintain?
apattidb
approved these changes
Nov 15, 2021
Static Val.Obj instances are created by the optimizer and will end up in the parse cache. If the cache is shared by multiple threads, initialization must be sufficiently safe, i.e. computing a value multiple times in race conditions is allowed (and cheaper than ensuring that it doesn't happen), but object must never get into an invalid intermediate state.
dd1fab5 to
c94a5a1
Compare
jam01
pushed a commit
to jam01/sjsonnet
that referenced
this pull request
Mar 7, 2022
Static Val.Obj instances are created by the optimizer and will end up in the parse cache. If the cache is shared by multiple threads, initialization must be sufficiently safe, i.e. computing a value multiple times in race conditions is allowed (and cheaper than ensuring that it doesn't happen), but object must never get into an invalid intermediate state.
stephenamar-db
pushed a commit
that referenced
this pull request
Nov 26, 2024
This PR fixes a thread-safety bug in Val.obj.getAllKeys, similar to the previous fix in #136. It looks like this particular site was overlooked in that earlier PR. I spotted this potential issue while reading through the code, not via actual use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static Val.Obj instances are created by the optimizer and will end up in the parse cache. If the cache is shared by multiple threads, initialization must be sufficiently safe, i.e. computing a value multiple times in race conditions is allowed (and cheaper than ensuring that it doesn't happen), but object must never get into an invalid intermediate state.