Skip to content
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

Lock: Add missing null check #66

Merged
merged 3 commits into from
Apr 7, 2021
Merged

Conversation

mfkl
Copy link
Contributor

@mfkl mfkl commented Feb 4, 2021

Fixes part of #65 (should be split in 2 issues).

This resulted in a NullReferenceException hiding the expected (?) LockNotHeldException.

This resulted in a NullReferenceException hiding the expected LockNotHeldException
G-Research#65
@mfkl
Copy link
Contributor Author

mfkl commented Feb 4, 2021

@georgy93 mentions

LockNotHeldException because this was the last thing from the method before the finally block. I'm not sure if this exception would be correct in case of cancellation token being cancelled. Could be, could be not.

Copy link
Contributor

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few remarks regarding the test code.


var distributedLock = _client.CreateLock(new LockOptions(keyName)
{
SessionTTL = TimeSpan.FromSeconds(DefaultSessionTTLSeconds),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that defining these values as constants improves the test readability, but I'm not against it either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me either way. #67 uses them too

Consul.Test/SemaphoreTest.cs Show resolved Hide resolved
Consul.Test/SemaphoreTest.cs Outdated Show resolved Hide resolved
Consul.Test/SemaphoreTest.cs Show resolved Hide resolved
@mfkl
Copy link
Contributor Author

mfkl commented Feb 11, 2021

Hi @georgy93, could you please review this PR and confirm this is your actual use case?

@georgy93
Copy link

georgy93 commented Feb 12, 2021

Hi @mfkl !
I played around with the changes and they seem okay to me (including #67 ).
No more null reference exceptions and when I cancel the cancellation token I get TaskCancelledException and the operation stops as expected.

@mfkl
Copy link
Contributor Author

mfkl commented Apr 7, 2021

Let's merge this? @marcin-krystianc @jgiannuzzi

@jgiannuzzi jgiannuzzi merged commit 0d8abda into G-Research:master Apr 7, 2021
@mfkl mfkl deleted the fix-null-ref-65 branch April 7, 2021 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants