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

Throw on existing healt check name, fixes #1245 #1247

Merged
merged 2 commits into from
Jan 4, 2018

Conversation

erikvanoosten
Copy link
Contributor

Throw an exception when registering a health check under an already existing name. This fixes #1245.

Copy link
Member

@arteam arteam left a comment

Choose a reason for hiding this comment

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

Looks good! I've left one suggestion.

if (registered != null) {
if (registered == null) {
throw new IllegalArgumentException("A health check named " + name + " already exists");
} else {
Copy link
Member

@arteam arteam Jan 4, 2018

Choose a reason for hiding this comment

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

It seems to me that it would be better to move throwing exception near to the containsKey check. It looks more logical (we check that the health check doesn't exist, otherwise throw an exception).

if (!healthChecks.containsKey(name)) {
  ....
} else {
  throw new IllegalArgumentException("A health check named " + name + " already exists");
}

Also this allows to remove the not null check before invoking the listeners, since the compiler will guarantee that registered will be always not null.

@arteam arteam merged commit a1464ab into dropwizard:4.1-development Jan 4, 2018
@arteam
Copy link
Member

arteam commented Jan 4, 2018

Thank you for the contribution!

@erikvanoosten
Copy link
Contributor Author

Thanks for merging so quickly 👍

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.

Inconsistency registring gauges and health checks
2 participants