Skip to content

Fix warning CA2002: Do not lock on objects with weak identity#13

Merged
gabikliot merged 1 commit intodotnet:masterfrom
zerhacken:dev/fix-storage-weak-identity-lock
Jan 26, 2015
Merged

Fix warning CA2002: Do not lock on objects with weak identity#13
gabikliot merged 1 commit intodotnet:masterfrom
zerhacken:dev/fix-storage-weak-identity-lock

Conversation

@zerhacken
Copy link
Copy Markdown
Contributor

This commit fixes warning CA2002. HierarchicalKeyStore extends
MarshalByRefObject which allows code code running in one AppDomain
to lock on an object in another AppDomain. Fix is to lock on a private
object which only HierarchicalKeyStore is knowledgeable about.

@gabikliot gabikliot self-assigned this Jan 25, 2015
@gabikliot
Copy link
Copy Markdown
Contributor

Hi

Thank you for this fix. 2 comments:

  1. We usually use the "lockable" to name the private object to lock on, instead of mutex. Just our internal naming convention.
  2. I think the original code in GrainTypeManager was correct. The lock has to be taken on a static field, since it has to be the same lock across different instances of the GrainTypeManager class. This is part of the singleton pattern.

@jthelin jthelin added the bug label Jan 25, 2015
@zerhacken
Copy link
Copy Markdown
Contributor Author

  1. Will rename "mutex" to "lockable"
  2. You are right, I will fix this to lock on a static field.

I will squash the commits on dev/fix-storage-weak-identity-lock and provide a decent commit message.

@zerhacken
Copy link
Copy Markdown
Contributor Author

Looks like the build failed "java.io.IOException: An existing connection was forcibly closed by the remote host"

Lock on a private object which only instance is knowledgeable about.
gabikliot added a commit that referenced this pull request Jan 26, 2015
Fix warning CA2002: Do not lock on objects with weak identity
@gabikliot gabikliot merged commit 899ac35 into dotnet:master Jan 26, 2015
ReubenBond pushed a commit to ReubenBond/orleans that referenced this pull request Apr 6, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants