From 98bb60e4baeb4e0c4d5cdd93e2422a4622283412 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 24 Nov 2014 21:27:14 +0100 Subject: [PATCH] improve assert Original commit: elastic/x-pack-elasticsearch@cfedeb5da8030c4c4f2c418bc5f6a1a35a73ccde --- src/main/java/org/elasticsearch/alerts/AlertsStore.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/alerts/AlertsStore.java b/src/main/java/org/elasticsearch/alerts/AlertsStore.java index afe4eafa12d..f4b991f5a5a 100644 --- a/src/main/java/org/elasticsearch/alerts/AlertsStore.java +++ b/src/main/java/org/elasticsearch/alerts/AlertsStore.java @@ -112,11 +112,17 @@ public class AlertsStore extends AbstractComponent { alert.version(response.getVersion()); // Don'<> need to update the alertMap, since we are working on an instance from it. - assert alertMap.get(alert.alertName()) == alert; + assert verifySameInstance(alert); return response; } + private boolean verifySameInstance(Alert alert) { + Alert found = alertMap.get(alert.alertName()); + assert found == alert : "expected " + alert + " but got" + found; + return true; + } + /** * Deletes the alert with the specified name if exists */