From c521219b2f078096f45ec082934de3701f0b71f7 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 22 Nov 2016 11:57:57 +0100 Subject: [PATCH] Adapt BWC layer checks for Exceptions to include v5.0.2 support The PR #21694 was initially planned to go into v6.0.0 and v5.1.0. Due to another PR relying on this one though for backport to v5.0.2, #21694 must go to v5.0.2 as well. As such, the initial backward compatibility rules established by the PR must be changed to include v5.0.2 and above. --- .../java/org/elasticsearch/ElasticsearchException.java | 5 +++-- .../org/elasticsearch/ExceptionSerializationTests.java | 8 ++++---- core/src/test/java/org/elasticsearch/VersionTests.java | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index a4befb67d4a..3db28cb3567 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -50,6 +50,7 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_UUID_NA_VAL public class ElasticsearchException extends RuntimeException implements ToXContent, Writeable { public static final Version V_5_1_0_UNRELEASED = Version.fromId(5010099); + public static final Version V_5_0_2_UNRELEASED = Version.fromId(5000299); public static final Version UNKNOWN_VERSION_ADDED = Version.fromId(0); public static final String REST_EXCEPTION_SKIP_CAUSE = "rest.exception.cause.skip"; public static final String REST_EXCEPTION_SKIP_STACK_TRACE = "rest.exception.stacktrace.skip"; @@ -709,9 +710,9 @@ public class ElasticsearchException extends RuntimeException implements ToXConte STATUS_EXCEPTION(org.elasticsearch.ElasticsearchStatusException.class, org.elasticsearch.ElasticsearchStatusException::new, 145, UNKNOWN_VERSION_ADDED), TASK_CANCELLED_EXCEPTION(org.elasticsearch.tasks.TaskCancelledException.class, - org.elasticsearch.tasks.TaskCancelledException::new, 146, UNKNOWN_VERSION_ADDED), + org.elasticsearch.tasks.TaskCancelledException::new, 146, V_5_1_0_UNRELEASED), SHARD_LOCK_OBTAIN_FAILED_EXCEPTION(org.elasticsearch.env.ShardLockObtainFailedException.class, - org.elasticsearch.env.ShardLockObtainFailedException::new, 147, V_5_1_0_UNRELEASED); + org.elasticsearch.env.ShardLockObtainFailedException::new, 147, V_5_0_2_UNRELEASED); final Class exceptionClass; diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 603272126b4..fa88e97e001 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -842,9 +842,9 @@ public class ExceptionSerializationTests extends ESTestCase { ShardLockObtainFailedException orig = new ShardLockObtainFailedException(shardId, "boom"); Version version = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.CURRENT); - if (version.before(ElasticsearchException.V_5_1_0_UNRELEASED)) { - // remove this once 5_1_0 is released randomVersionBetween asserts that this version is in the constant table.. - version = ElasticsearchException.V_5_1_0_UNRELEASED; + if (version.before(ElasticsearchException.V_5_0_2_UNRELEASED)) { + // remove this once 5_0_2 is released randomVersionBetween asserts that this version is in the constant table.. + version = ElasticsearchException.V_5_0_2_UNRELEASED; } ShardLockObtainFailedException ex = serialize(orig, version); assertEquals(orig.getMessage(), ex.getMessage()); @@ -854,7 +854,7 @@ public class ExceptionSerializationTests extends ESTestCase { public void testBWCShardLockObtainFailedException() throws IOException { ShardId shardId = new ShardId("foo", "_na_", 1); ShardLockObtainFailedException orig = new ShardLockObtainFailedException(shardId, "boom"); - Exception ex = serialize((Exception)orig, Version.V_5_0_0); + Exception ex = serialize((Exception)orig, randomFrom(Version.V_5_0_0, Version.V_5_0_1)); assertThat(ex, instanceOf(NotSerializableExceptionWrapper.class)); assertEquals("shard_lock_obtain_failed_exception: [foo][1]: boom", ex.getMessage()); } diff --git a/core/src/test/java/org/elasticsearch/VersionTests.java b/core/src/test/java/org/elasticsearch/VersionTests.java index 1e87f7eeb31..fb21942212c 100644 --- a/core/src/test/java/org/elasticsearch/VersionTests.java +++ b/core/src/test/java/org/elasticsearch/VersionTests.java @@ -285,6 +285,7 @@ public class VersionTests extends ESTestCase { assertUnknownVersion(QueryStringQueryBuilder.V_5_1_0_UNRELEASED); assertUnknownVersion(SimpleQueryStringBuilder.V_5_1_0_UNRELEASED); assertUnknownVersion(ElasticsearchException.V_5_1_0_UNRELEASED); + assertUnknownVersion(ElasticsearchException.V_5_0_2_UNRELEASED); // once we released 5.0.0 and it's added to Version.java we need to remove this constant assertUnknownVersion(Script.V_5_1_0_UNRELEASED); // once we released 5.0.0 and it's added to Version.java we need to remove this constant