From 9eaee3da8d4c03ae442f7b31bbb3977d143caf5c Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Tue, 2 Jun 2020 16:47:11 -0600 Subject: [PATCH] Fix exception check in RecoveryRequestTrackerTests (#57493) Currently we check that exceptions are the same in the recovery request tracker test. This is inconsistent because the future wraps the exception in a new instance. This commit fixes the test by comparing a random exception message. Fixes #57199 --- .../indices/recovery/RecoveryRequestTrackerTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryRequestTrackerTests.java b/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryRequestTrackerTests.java index c7fcfba229c..54eb8eef1a3 100644 --- a/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryRequestTrackerTests.java +++ b/server/src/test/java/org/elasticsearch/indices/recovery/RecoveryRequestTrackerTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.indices.recovery; +import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; @@ -68,7 +69,7 @@ public class RecoveryRequestTrackerTests extends ESTestCase { // Ensure that we only return 1 future per sequence number assertTrue(added); if (rarely()) { - listener.onFailure(new Exception()); + listener.onFailure(new ElasticsearchException(randomAlphaOfLength(10))); } else { listener.onResponse(null); } @@ -103,7 +104,7 @@ public class RecoveryRequestTrackerTests extends ESTestCase { future.actionGet(); fail("expected exception"); } catch (Exception e) { - assertSame(e, expectedException); + assertEquals(expectedException.getMessage(), e.getMessage()); } } }