-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make alert conditions resilient against changing number formats. #2182
Conversation
Adding some tests as well. |
In 1.3.x numerical alert condition parameters were stored by MongoDB (resp. the mongo java driver) in a way, that they are returned as Doubles to the server, while alert conditions persisted in 2.0.0 return numerical parameters as Integer. Therefore, 2.0.0 cannot handle alert conditions stored in 1.3.x, so legacy installations upgraded to 2.0.0 do not check any alert conditions anymore. This change allows to handle both formats by generally assuming they are Number/Double types and returning their `intValue()`. Fixes #2169
This also helps us, because the "threshold" parameter could also be a double in some cases.
@@ -195,4 +187,16 @@ public NegativeCheckResult(AlertCondition alertCondition) { | |||
} | |||
} | |||
|
|||
@VisibleForTesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor semantic nitpick: Child classes are also using this (protected) method, so it's not just visible for testing. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use wildcard imports.
Configuration for IntelliJ IDEA: http://stackoverflow.com/a/3348855
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
LGTM (except for those 2 minor nitpicks). 👍 |
LGTM. 👍 |
In 1.3.x numerical alert condition parameters were stored by MongoDB (resp. the Mongo Java Driver) in a way, that they are returned as Double while alert conditions persisted in 2.0.0 return numerical parameters as Integer. Therefore, 2.0.0 cannot handle alert conditions stored in 1.3.x and legacy installations upgraded to 2.0.0 do not check any alert conditions anymore. This change allows to handle both formats by generally assuming they are Number/Double types and returning their `intValue()`. Fixes #2169 (cherry picked from commit d164e7f)
In 1.3.x numerical alert condition parameters were stored by MongoDB
(resp. the mongo java driver) in a way, that they are returned as
Doubles to the server, while alert conditions persisted in 2.0.0 return
numerical parameters as Integer. Therefore, 2.0.0 cannot handle alert
conditions stored in 1.3.x, so legacy installations upgraded to 2.0.0
do not check any alert conditions anymore.
This change allows to handle both formats by generally assuming they are
Number/Double types and returning their
intValue()
.Fixes #2169