8000 Getting contents of lock without acquiring the lock · Issue #52 · cirello-io/dynamolock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Getting contents of lock without acquiring the lock #52

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
aashishkapur opened this issue Oct 3, 2019 · 3 comments
Closed

Getting contents of lock without acquiring the lock #52

aashishkapur opened this issue Oct 3, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@aashishkapur
Copy link

Hi,
I was trying to get the contents of a lock without acquiring the lock, but found that when I tried to get the lock,

lock, err = client.Get(dynamoLockName)

I received a lock with no data.

I looked into Get, and found that this branch was getting executed: https://github.com/cirello-io/dynamolock/blob/master/client.go#L906, because the lock is currently not held. Therefore, an empty lock is returned, with no data.

I'm happy to make a PR to fix this by removing the lockItem.isReleased check, but wanted to confirm.

@aashishkapur
Copy link
Author

code snippet:

lock, err := client.Get("spock")
if err != nil {
	log.Fatal(err)
}

log.Println("lock content:", string(lockedItem.Data()))
//this is empty

@ucirello ucirello added bug Something isn't working waiting-feedback and removed bug Something isn't working labels Oct 3, 2019
@ucirello
Copy link
Collaborator
ucirello commented Oct 3, 2019

@aashishkapur thanks for the report. I suspect the code is working fine. I just reviewed the tests here, and they do seem to validate Get(). Could you provide a piece of code that proves the problem?

Also, I suggest you refer to the test TestReadLockContent in client_test.go (https://github.com/cirello-io/dynamolock/blob/master/client_test.go#L149-L209) which shows how to use this feature.

@ucirello ucirello closed this as completed Oct 3, 2019
@ucirello
Copy link
Collaborator
ucirello commented Oct 3, 2019

Hi @aashishkapur - I found the bug. Thanks for the report. The fix is merged.

@ucirello ucirello added bug Something isn't working and removed waiting-feedback labels Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants
0