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

fix(client): Checks if the gateway is already closed before trying to shutdown the gateway #104

Conversation

bulldetektor
Copy link
Contributor

related to #39

}
catch (System.Exception)
{
// ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please lets not ignore exceptions. Is there a specific reason for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because Dispose() should never throw exceptions, and there's no guarantee that ShutdownAsync won't throw here (in fact there's a fair chance it actually will throw...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That said; If you'd rather have the exception be thrown here, I can remove the try-catch. The real fix is the guard above that will make sure we're not calling ShotdownAsync() on a ClosedGatewayClient (which is guaranteed to throw an exception)

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah lets remove it

@ChrisKujawa
Copy link
Collaborator

Hey @bulldetektor first of all thanks so much for your contribution I appreciate it!

Is there a reason why implemented for the PublishMessageCommand only and how is it related to #39?

@bulldetektor
Copy link
Contributor Author

bulldetektor commented Apr 3, 2020

The relation to #39 is that handling exceptions in Dispose will get you closer to a graceful shutdown of the client. So I'm not stating that it will close the issue, but it will make the shutdown "more" graceful :)

As for why I only implemented it for the PublishMessageCommand; That's because I'm not familiar enough with the code base to start doing major refactorings, and this was just to patch up the errors that we were experiencing when using the client. I could probably do the same for the rest of the commands, but not sure if you'd appreciate such I large change from a first-time committer on the project :)

@ChrisKujawa
Copy link
Collaborator

@bulldetektor ah thanks for the explanation, makes sense thanks. I have overseen that you used the related mark. I thought it was closes.

I assume we could also add an unit test that we can close the client twice.

@bulldetektor
Copy link
Contributor Author

@Zelldon I removed the try-catch and added a unit test that verifies that Dispose does not throw any exceptions when called multiple times (also checked that the test fails when I remove my fix)

Copy link
Collaborator

@ChrisKujawa ChrisKujawa left a comment

Choose a reason for hiding this comment

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

Awesome thanks 👍

@ChrisKujawa ChrisKujawa merged commit 110d7d7 into camunda-community-hub:master Apr 14, 2020
@bulldetektor bulldetektor deleted the fix/do_not_throw_on_dispose branch April 14, 2020 06:59
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.

2 participants