diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchException.java b/server/src/main/java/org/elasticsearch/ElasticsearchException.java index a46eac0c31a74..38d42c9bc567b 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/server/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -87,8 +87,6 @@ */ public class ElasticsearchException extends RuntimeException implements ToXContentFragment, Writeable { - private static final TransportVersion UNKNOWN_VERSION_ADDED = TransportVersion.zero(); - /** * Passed in the {@link Params} of {@link #generateThrowableXContent(XContentBuilder, Params, Throwable)} * to control if the {@code caused_by} element should render. Unlike most parameters to {@code toXContent} methods this parameter is @@ -403,8 +401,7 @@ public static ElasticsearchException readException(StreamInput input, int id) th public static boolean isRegistered(Class exception, TransportVersion version) { ElasticsearchExceptionHandle elasticsearchExceptionHandle = CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE.get(exception); if (elasticsearchExceptionHandle != null) { - return version.onOrAfter(elasticsearchExceptionHandle.versionAdded) - || Arrays.stream(elasticsearchExceptionHandle.patchVersions).anyMatch(version::isPatchFrom); + return version.supports(elasticsearchExceptionHandle.minimumCompatible); } return false; } @@ -1109,147 +1106,147 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException::new, 0, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), DFS_PHASE_EXECUTION_EXCEPTION( org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, org.elasticsearch.search.dfs.DfsPhaseExecutionException::new, 1, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), EXECUTION_CANCELLED_EXCEPTION( org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, 2, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), MASTER_NOT_DISCOVERED_EXCEPTION( org.elasticsearch.discovery.MasterNotDiscoveredException.class, org.elasticsearch.discovery.MasterNotDiscoveredException::new, 3, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ELASTICSEARCH_SECURITY_EXCEPTION( org.elasticsearch.ElasticsearchSecurityException.class, org.elasticsearch.ElasticsearchSecurityException::new, 4, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_RESTORE_EXCEPTION( org.elasticsearch.index.snapshots.IndexShardRestoreException.class, org.elasticsearch.index.snapshots.IndexShardRestoreException::new, 5, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_CLOSED_EXCEPTION( org.elasticsearch.indices.IndexClosedException.class, org.elasticsearch.indices.IndexClosedException::new, 6, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), BIND_HTTP_EXCEPTION( org.elasticsearch.http.BindHttpException.class, org.elasticsearch.http.BindHttpException::new, 7, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REDUCE_SEARCH_PHASE_EXCEPTION( org.elasticsearch.action.search.ReduceSearchPhaseException.class, org.elasticsearch.action.search.ReduceSearchPhaseException::new, 8, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NODE_CLOSED_EXCEPTION( org.elasticsearch.node.NodeClosedException.class, org.elasticsearch.node.NodeClosedException::new, 9, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 10 was for SnapshotFailedEngineException, never instantiated in 6.2.0+ and never thrown across clusters SHARD_NOT_FOUND_EXCEPTION( org.elasticsearch.index.shard.ShardNotFoundException.class, org.elasticsearch.index.shard.ShardNotFoundException::new, 11, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), CONNECT_TRANSPORT_EXCEPTION( org.elasticsearch.transport.ConnectTransportException.class, org.elasticsearch.transport.ConnectTransportException::new, 12, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NOT_SERIALIZABLE_TRANSPORT_EXCEPTION( org.elasticsearch.transport.NotSerializableTransportException.class, org.elasticsearch.transport.NotSerializableTransportException::new, 13, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RESPONSE_HANDLER_FAILURE_TRANSPORT_EXCEPTION( org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, org.elasticsearch.transport.ResponseHandlerFailureTransportException::new, 14, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_CREATION_EXCEPTION( org.elasticsearch.indices.IndexCreationException.class, org.elasticsearch.indices.IndexCreationException::new, 15, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_NOT_FOUND_EXCEPTION( org.elasticsearch.index.IndexNotFoundException.class, org.elasticsearch.index.IndexNotFoundException::new, 16, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ILLEGAL_SHARD_ROUTING_STATE_EXCEPTION( org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, org.elasticsearch.cluster.routing.IllegalShardRoutingStateException::new, 17, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), BROADCAST_SHARD_OPERATION_FAILED_EXCEPTION( org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException::new, 18, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RESOURCE_NOT_FOUND_EXCEPTION( org.elasticsearch.ResourceNotFoundException.class, org.elasticsearch.ResourceNotFoundException::new, 19, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ACTION_TRANSPORT_EXCEPTION( org.elasticsearch.transport.ActionTransportException.class, org.elasticsearch.transport.ActionTransportException::new, 20, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ELASTICSEARCH_GENERATION_EXCEPTION( org.elasticsearch.ElasticsearchGenerationException.class, org.elasticsearch.ElasticsearchGenerationException::new, 21, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 22 was CreateFailedEngineException INDEX_SHARD_STARTED_EXCEPTION( org.elasticsearch.index.shard.IndexShardStartedException.class, org.elasticsearch.index.shard.IndexShardStartedException::new, 23, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SEARCH_CONTEXT_MISSING_EXCEPTION( org.elasticsearch.search.SearchContextMissingException.class, org.elasticsearch.search.SearchContextMissingException::new, 24, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), GENERAL_SCRIPT_EXCEPTION( org.elasticsearch.script.GeneralScriptException.class, org.elasticsearch.script.GeneralScriptException::new, 25, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 26 was BatchOperationException // 27 was SnapshotCreationException @@ -1258,103 +1255,103 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.index.engine.DocumentMissingException.class, org.elasticsearch.index.engine.DocumentMissingException::new, 29, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SNAPSHOT_EXCEPTION( org.elasticsearch.snapshots.SnapshotException.class, org.elasticsearch.snapshots.SnapshotException::new, 30, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INVALID_ALIAS_NAME_EXCEPTION( org.elasticsearch.indices.InvalidAliasNameException.class, org.elasticsearch.indices.InvalidAliasNameException::new, 31, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INVALID_INDEX_NAME_EXCEPTION( org.elasticsearch.indices.InvalidIndexNameException.class, org.elasticsearch.indices.InvalidIndexNameException::new, 32, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_PRIMARY_SHARD_NOT_ALLOCATED_EXCEPTION( org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException::new, 33, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TRANSPORT_EXCEPTION( org.elasticsearch.transport.TransportException.class, org.elasticsearch.transport.TransportException::new, 34, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ELASTICSEARCH_PARSE_EXCEPTION( org.elasticsearch.ElasticsearchParseException.class, org.elasticsearch.ElasticsearchParseException::new, 35, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SEARCH_EXCEPTION( org.elasticsearch.search.SearchException.class, org.elasticsearch.search.SearchException::new, 36, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), MAPPER_EXCEPTION( org.elasticsearch.index.mapper.MapperException.class, org.elasticsearch.index.mapper.MapperException::new, 37, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INVALID_TYPE_NAME_EXCEPTION( org.elasticsearch.indices.InvalidTypeNameException.class, org.elasticsearch.indices.InvalidTypeNameException::new, 38, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SNAPSHOT_RESTORE_EXCEPTION( org.elasticsearch.snapshots.SnapshotRestoreException.class, org.elasticsearch.snapshots.SnapshotRestoreException::new, 39, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), PARSING_EXCEPTION( org.elasticsearch.common.ParsingException.class, org.elasticsearch.common.ParsingException::new, 40, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_CLOSED_EXCEPTION( org.elasticsearch.index.shard.IndexShardClosedException.class, org.elasticsearch.index.shard.IndexShardClosedException::new, 41, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RECOVER_FILES_RECOVERY_EXCEPTION( org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, org.elasticsearch.indices.recovery.RecoverFilesRecoveryException::new, 42, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TRUNCATED_TRANSLOG_EXCEPTION( org.elasticsearch.index.translog.TruncatedTranslogException.class, org.elasticsearch.index.translog.TruncatedTranslogException::new, 43, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RECOVERY_FAILED_EXCEPTION( org.elasticsearch.indices.recovery.RecoveryFailedException.class, org.elasticsearch.indices.recovery.RecoveryFailedException::new, 44, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_RELOCATED_EXCEPTION( org.elasticsearch.index.shard.IndexShardRelocatedException.class, org.elasticsearch.index.shard.IndexShardRelocatedException::new, 45, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 46 was for NodeShouldNotConnectException, never instantiated in 5.0+ // 47 used to be for IndexTemplateAlreadyExistsException which was deprecated in 5.1 removed in 6.0 @@ -1362,57 +1359,57 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.index.translog.TranslogCorruptedException.class, org.elasticsearch.index.translog.TranslogCorruptedException::new, 48, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), CLUSTER_BLOCK_EXCEPTION( org.elasticsearch.cluster.block.ClusterBlockException.class, org.elasticsearch.cluster.block.ClusterBlockException::new, 49, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), FETCH_PHASE_EXECUTION_EXCEPTION( org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, org.elasticsearch.search.fetch.FetchPhaseExecutionException::new, 50, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 51 used to be for IndexShardAlreadyExistsException which was deprecated in 5.1 removed in 6.0 VERSION_CONFLICT_ENGINE_EXCEPTION( org.elasticsearch.index.engine.VersionConflictEngineException.class, org.elasticsearch.index.engine.VersionConflictEngineException::new, 52, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ENGINE_EXCEPTION( org.elasticsearch.index.engine.EngineException.class, org.elasticsearch.index.engine.EngineException::new, 53, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 54 was DocumentAlreadyExistsException, which is superseded by VersionConflictEngineException NO_SUCH_NODE_EXCEPTION( org.elasticsearch.action.NoSuchNodeException.class, org.elasticsearch.action.NoSuchNodeException::new, 55, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SETTINGS_EXCEPTION( org.elasticsearch.common.settings.SettingsException.class, org.elasticsearch.common.settings.SettingsException::new, 56, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_TEMPLATE_MISSING_EXCEPTION( org.elasticsearch.indices.IndexTemplateMissingException.class, org.elasticsearch.indices.IndexTemplateMissingException::new, 57, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SEND_REQUEST_TRANSPORT_EXCEPTION( org.elasticsearch.transport.SendRequestTransportException.class, org.elasticsearch.transport.SendRequestTransportException::new, 58, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 59 used to be EsRejectedExecutionException // 60 used to be for EarlyTerminationException @@ -1421,13 +1418,13 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper::new, 62, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ALIAS_FILTER_PARSING_EXCEPTION( org.elasticsearch.indices.AliasFilterParsingException.class, org.elasticsearch.indices.AliasFilterParsingException::new, 63, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 64 was DeleteByQueryFailedEngineException, which was removed in 5.0 // 65 was for GatewayException, never instantiated in 5.0+ @@ -1435,304 +1432,309 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, org.elasticsearch.index.shard.IndexShardNotRecoveringException::new, 66, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() + ), + HTTP_EXCEPTION( + org.elasticsearch.http.HttpException.class, + org.elasticsearch.http.HttpException::new, + 67, + TransportVersion.minimumCompatible() ), - HTTP_EXCEPTION(org.elasticsearch.http.HttpException.class, org.elasticsearch.http.HttpException::new, 67, UNKNOWN_VERSION_ADDED), ELASTICSEARCH_EXCEPTION( org.elasticsearch.ElasticsearchException.class, org.elasticsearch.ElasticsearchException::new, 68, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SNAPSHOT_MISSING_EXCEPTION( org.elasticsearch.snapshots.SnapshotMissingException.class, org.elasticsearch.snapshots.SnapshotMissingException::new, 69, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), PRIMARY_MISSING_ACTION_EXCEPTION( org.elasticsearch.action.PrimaryMissingActionException.class, org.elasticsearch.action.PrimaryMissingActionException::new, 70, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), FAILED_NODE_EXCEPTION( org.elasticsearch.action.FailedNodeException.class, org.elasticsearch.action.FailedNodeException::new, 71, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 72 was SearchParseException, only used in tests after 7.11 CONCURRENT_SNAPSHOT_EXECUTION_EXCEPTION( org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException::new, 73, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), BLOB_STORE_EXCEPTION( org.elasticsearch.common.blobstore.BlobStoreException.class, org.elasticsearch.common.blobstore.BlobStoreException::new, 74, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INCOMPATIBLE_CLUSTER_STATE_VERSION_EXCEPTION( org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, org.elasticsearch.cluster.IncompatibleClusterStateVersionException::new, 75, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RECOVERY_ENGINE_EXCEPTION( org.elasticsearch.index.engine.RecoveryEngineException.class, org.elasticsearch.index.engine.RecoveryEngineException::new, 76, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), UNCATEGORIZED_EXECUTION_EXCEPTION( org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, org.elasticsearch.common.util.concurrent.UncategorizedExecutionException::new, 77, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TIMESTAMP_PARSING_EXCEPTION( org.elasticsearch.action.TimestampParsingException.class, org.elasticsearch.action.TimestampParsingException::new, 78, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ROUTING_MISSING_EXCEPTION( org.elasticsearch.action.RoutingMissingException.class, org.elasticsearch.action.RoutingMissingException::new, 79, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 80 was IndexFailedEngineException, deprecated in 6.0, removed in 7.0 INDEX_SHARD_RESTORE_FAILED_EXCEPTION( org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, org.elasticsearch.index.snapshots.IndexShardRestoreFailedException::new, 81, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REPOSITORY_EXCEPTION( org.elasticsearch.repositories.RepositoryException.class, org.elasticsearch.repositories.RepositoryException::new, 82, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RECEIVE_TIMEOUT_TRANSPORT_EXCEPTION( org.elasticsearch.transport.ReceiveTimeoutTransportException.class, org.elasticsearch.transport.ReceiveTimeoutTransportException::new, 83, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NODE_DISCONNECTED_EXCEPTION( org.elasticsearch.transport.NodeDisconnectedException.class, org.elasticsearch.transport.NodeDisconnectedException::new, 84, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 85 used to be for AlreadyExpiredException AGGREGATION_EXECUTION_EXCEPTION( org.elasticsearch.search.aggregations.AggregationExecutionException.class, org.elasticsearch.search.aggregations.AggregationExecutionException::new, 86, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 87 used to be for MergeMappingException INVALID_INDEX_TEMPLATE_EXCEPTION( org.elasticsearch.indices.InvalidIndexTemplateException.class, org.elasticsearch.indices.InvalidIndexTemplateException::new, 88, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REFRESH_FAILED_ENGINE_EXCEPTION( org.elasticsearch.index.engine.RefreshFailedEngineException.class, org.elasticsearch.index.engine.RefreshFailedEngineException::new, 90, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), AGGREGATION_INITIALIZATION_EXCEPTION( org.elasticsearch.search.aggregations.AggregationInitializationException.class, org.elasticsearch.search.aggregations.AggregationInitializationException::new, 91, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), DELAY_RECOVERY_EXCEPTION( org.elasticsearch.indices.recovery.DelayRecoveryException.class, org.elasticsearch.indices.recovery.DelayRecoveryException::new, 92, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 93 used to be for IndexWarmerMissingException NO_NODE_AVAILABLE_EXCEPTION( org.elasticsearch.client.internal.transport.NoNodeAvailableException.class, org.elasticsearch.client.internal.transport.NoNodeAvailableException::new, 94, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INVALID_SNAPSHOT_NAME_EXCEPTION( org.elasticsearch.snapshots.InvalidSnapshotNameException.class, org.elasticsearch.snapshots.InvalidSnapshotNameException::new, 96, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ILLEGAL_INDEX_SHARD_STATE_EXCEPTION( org.elasticsearch.index.shard.IllegalIndexShardStateException.class, org.elasticsearch.index.shard.IllegalIndexShardStateException::new, 97, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_SNAPSHOT_EXCEPTION( org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, org.elasticsearch.index.snapshots.IndexShardSnapshotException::new, 98, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_NOT_STARTED_EXCEPTION( org.elasticsearch.index.shard.IndexShardNotStartedException.class, org.elasticsearch.index.shard.IndexShardNotStartedException::new, 99, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SEARCH_PHASE_EXECUTION_EXCEPTION( org.elasticsearch.action.search.SearchPhaseExecutionException.class, org.elasticsearch.action.search.SearchPhaseExecutionException::new, 100, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ACTION_NOT_FOUND_TRANSPORT_EXCEPTION( org.elasticsearch.transport.ActionNotFoundTransportException.class, org.elasticsearch.transport.ActionNotFoundTransportException::new, 101, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TRANSPORT_SERIALIZATION_EXCEPTION( org.elasticsearch.transport.TransportSerializationException.class, org.elasticsearch.transport.TransportSerializationException::new, 102, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REMOTE_TRANSPORT_EXCEPTION( org.elasticsearch.transport.RemoteTransportException.class, org.elasticsearch.transport.RemoteTransportException::new, 103, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ENGINE_CREATION_FAILURE_EXCEPTION( org.elasticsearch.index.engine.EngineCreationFailureException.class, org.elasticsearch.index.engine.EngineCreationFailureException::new, 104, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ROUTING_EXCEPTION( org.elasticsearch.cluster.routing.RoutingException.class, org.elasticsearch.cluster.routing.RoutingException::new, 105, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_RECOVERY_EXCEPTION( org.elasticsearch.index.shard.IndexShardRecoveryException.class, org.elasticsearch.index.shard.IndexShardRecoveryException::new, 106, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REPOSITORY_MISSING_EXCEPTION( org.elasticsearch.repositories.RepositoryMissingException.class, org.elasticsearch.repositories.RepositoryMissingException::new, 107, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), DOCUMENT_SOURCE_MISSING_EXCEPTION( org.elasticsearch.index.engine.DocumentSourceMissingException.class, org.elasticsearch.index.engine.DocumentSourceMissingException::new, 109, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 110 used to be FlushNotAllowedEngineException NO_CLASS_SETTINGS_EXCEPTION( org.elasticsearch.common.settings.NoClassSettingsException.class, org.elasticsearch.common.settings.NoClassSettingsException::new, 111, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), BIND_TRANSPORT_EXCEPTION( org.elasticsearch.transport.BindTransportException.class, org.elasticsearch.transport.BindTransportException::new, 112, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ALIASES_NOT_FOUND_EXCEPTION( org.elasticsearch.rest.action.admin.indices.AliasesNotFoundException.class, org.elasticsearch.rest.action.admin.indices.AliasesNotFoundException::new, 113, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INDEX_SHARD_RECOVERING_EXCEPTION( org.elasticsearch.index.shard.IndexShardRecoveringException.class, org.elasticsearch.index.shard.IndexShardRecoveringException::new, 114, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TRANSLOG_EXCEPTION( org.elasticsearch.index.translog.TranslogException.class, org.elasticsearch.index.translog.TranslogException::new, 115, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), PROCESS_CLUSTER_EVENT_TIMEOUT_EXCEPTION( org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException::new, 116, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RETRY_ON_PRIMARY_EXCEPTION( ReplicationOperation.RetryOnPrimaryException.class, ReplicationOperation.RetryOnPrimaryException::new, 117, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), ELASTICSEARCH_TIMEOUT_EXCEPTION( org.elasticsearch.ElasticsearchTimeoutException.class, org.elasticsearch.ElasticsearchTimeoutException::new, 118, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), QUERY_PHASE_EXECUTION_EXCEPTION( org.elasticsearch.search.query.QueryPhaseExecutionException.class, org.elasticsearch.search.query.QueryPhaseExecutionException::new, 119, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REPOSITORY_VERIFICATION_EXCEPTION( org.elasticsearch.repositories.RepositoryVerificationException.class, org.elasticsearch.repositories.RepositoryVerificationException::new, 120, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INVALID_AGGREGATION_PATH_EXCEPTION( org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, org.elasticsearch.search.aggregations.InvalidAggregationPathException::new, 121, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 123 used to be IndexAlreadyExistsException and was renamed RESOURCE_ALREADY_EXISTS_EXCEPTION( ResourceAlreadyExistsException.class, ResourceAlreadyExistsException::new, 123, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 124 used to be Script.ScriptParseException HTTP_REQUEST_ON_TRANSPORT_EXCEPTION( TcpTransport.HttpRequestOnTransportException.class, TcpTransport.HttpRequestOnTransportException::new, 125, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), MAPPER_PARSING_EXCEPTION( org.elasticsearch.index.mapper.MapperParsingException.class, org.elasticsearch.index.mapper.MapperParsingException::new, 126, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 127 used to be org.elasticsearch.search.SearchContextException // 128 used to be org.elasticsearch.search.builder.SearchSourceBuilderException @@ -1741,290 +1743,299 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.action.NoShardAvailableActionException.class, org.elasticsearch.action.NoShardAvailableActionException::new, 130, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), UNAVAILABLE_SHARDS_EXCEPTION( org.elasticsearch.action.UnavailableShardsException.class, org.elasticsearch.action.UnavailableShardsException::new, 131, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), FLUSH_FAILED_ENGINE_EXCEPTION( org.elasticsearch.index.engine.FlushFailedEngineException.class, org.elasticsearch.index.engine.FlushFailedEngineException::new, 132, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), CIRCUIT_BREAKING_EXCEPTION( org.elasticsearch.common.breaker.CircuitBreakingException.class, org.elasticsearch.common.breaker.CircuitBreakingException::new, 133, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NODE_NOT_CONNECTED_EXCEPTION( org.elasticsearch.transport.NodeNotConnectedException.class, org.elasticsearch.transport.NodeNotConnectedException::new, 134, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), STRICT_DYNAMIC_MAPPING_EXCEPTION( org.elasticsearch.index.mapper.StrictDynamicMappingException.class, org.elasticsearch.index.mapper.StrictDynamicMappingException::new, 135, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RETRY_ON_REPLICA_EXCEPTION( org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException::new, 136, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TYPE_MISSING_EXCEPTION( org.elasticsearch.indices.TypeMissingException.class, org.elasticsearch.indices.TypeMissingException::new, 137, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), FAILED_TO_COMMIT_CLUSTER_STATE_EXCEPTION( org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException.class, org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException::new, 140, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), QUERY_SHARD_EXCEPTION( org.elasticsearch.index.query.QueryShardException.class, org.elasticsearch.index.query.QueryShardException::new, 141, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NO_LONGER_PRIMARY_SHARD_EXCEPTION( ShardStateAction.NoLongerPrimaryShardException.class, ShardStateAction.NoLongerPrimaryShardException::new, 142, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SCRIPT_EXCEPTION( org.elasticsearch.script.ScriptException.class, org.elasticsearch.script.ScriptException::new, 143, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NOT_MASTER_EXCEPTION( org.elasticsearch.cluster.NotMasterException.class, org.elasticsearch.cluster.NotMasterException::new, 144, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), STATUS_EXCEPTION( org.elasticsearch.ElasticsearchStatusException.class, org.elasticsearch.ElasticsearchStatusException::new, 145, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), TASK_CANCELLED_EXCEPTION( org.elasticsearch.tasks.TaskCancelledException.class, org.elasticsearch.tasks.TaskCancelledException::new, 146, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SHARD_LOCK_OBTAIN_FAILED_EXCEPTION( org.elasticsearch.env.ShardLockObtainFailedException.class, org.elasticsearch.env.ShardLockObtainFailedException::new, 147, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), // 148 was UnknownNamedObjectException TOO_MANY_BUCKETS_EXCEPTION( MultiBucketConsumerService.TooManyBucketsException.class, MultiBucketConsumerService.TooManyBucketsException::new, 149, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), COORDINATION_STATE_REJECTED_EXCEPTION( org.elasticsearch.cluster.coordination.CoordinationStateRejectedException.class, org.elasticsearch.cluster.coordination.CoordinationStateRejectedException::new, 150, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SNAPSHOT_IN_PROGRESS_EXCEPTION( org.elasticsearch.snapshots.SnapshotInProgressException.class, org.elasticsearch.snapshots.SnapshotInProgressException::new, 151, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NO_SUCH_REMOTE_CLUSTER_EXCEPTION( org.elasticsearch.transport.NoSuchRemoteClusterException.class, org.elasticsearch.transport.NoSuchRemoteClusterException::new, 152, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RETENTION_LEASE_ALREADY_EXISTS_EXCEPTION( org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException.class, org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException::new, 153, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RETENTION_LEASE_NOT_FOUND_EXCEPTION( org.elasticsearch.index.seqno.RetentionLeaseNotFoundException.class, org.elasticsearch.index.seqno.RetentionLeaseNotFoundException::new, 154, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), SHARD_NOT_IN_PRIMARY_MODE_EXCEPTION( org.elasticsearch.index.shard.ShardNotInPrimaryModeException.class, org.elasticsearch.index.shard.ShardNotInPrimaryModeException::new, 155, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), RETENTION_LEASE_INVALID_RETAINING_SEQUENCE_NUMBER_EXCEPTION( org.elasticsearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException.class, org.elasticsearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException::new, 156, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), INGEST_PROCESSOR_EXCEPTION( org.elasticsearch.ingest.IngestProcessorException.class, org.elasticsearch.ingest.IngestProcessorException::new, 157, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), PEER_RECOVERY_NOT_FOUND_EXCEPTION( org.elasticsearch.indices.recovery.PeerRecoveryNotFound.class, org.elasticsearch.indices.recovery.PeerRecoveryNotFound::new, 158, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), NODE_HEALTH_CHECK_FAILURE_EXCEPTION( org.elasticsearch.cluster.coordination.NodeHealthCheckFailureException.class, org.elasticsearch.cluster.coordination.NodeHealthCheckFailureException::new, 159, - TransportVersions.V_8_0_0 + TransportVersion.minimumCompatible() ), NO_SEED_NODE_LEFT_EXCEPTION( org.elasticsearch.transport.NoSeedNodeLeftException.class, org.elasticsearch.transport.NoSeedNodeLeftException::new, 160, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), AUTHENTICATION_PROCESSING_ERROR( org.elasticsearch.ElasticsearchAuthenticationProcessingError.class, org.elasticsearch.ElasticsearchAuthenticationProcessingError::new, 162, - UNKNOWN_VERSION_ADDED + TransportVersion.minimumCompatible() ), REPOSITORY_CONFLICT_EXCEPTION( org.elasticsearch.repositories.RepositoryConflictException.class, org.elasticsearch.repositories.RepositoryConflictException::new, 163, - TransportVersions.V_8_0_0 + TransportVersion.minimumCompatible() ), DESIRED_NODES_VERSION_CONFLICT_EXCEPTION( org.elasticsearch.cluster.desirednodes.VersionConflictException.class, org.elasticsearch.cluster.desirednodes.VersionConflictException::new, 164, - TransportVersions.V_8_1_0 + TransportVersion.minimumCompatible() ), SNAPSHOT_NAME_ALREADY_IN_USE_EXCEPTION( org.elasticsearch.snapshots.SnapshotNameAlreadyInUseException.class, org.elasticsearch.snapshots.SnapshotNameAlreadyInUseException::new, 165, - TransportVersions.V_8_2_0 + TransportVersion.minimumCompatible() ), HEALTH_NODE_NOT_DISCOVERED_EXCEPTION( HealthNodeNotDiscoveredException.class, HealthNodeNotDiscoveredException::new, 166, - TransportVersions.V_8_5_0 + TransportVersion.minimumCompatible() ), UNSUPPORTED_AGGREGATION_ON_DOWNSAMPLED_INDEX_EXCEPTION( UnsupportedAggregationOnDownsampledIndex.class, UnsupportedAggregationOnDownsampledIndex::new, 167, - TransportVersions.V_8_5_0 + TransportVersion.minimumCompatible() + ), + DOCUMENT_PARSING_EXCEPTION( + DocumentParsingException.class, + DocumentParsingException::new, + 168, + TransportVersion.minimumCompatible() ), - DOCUMENT_PARSING_EXCEPTION(DocumentParsingException.class, DocumentParsingException::new, 168, TransportVersions.V_8_8_0), HTTP_HEADERS_VALIDATION_EXCEPTION( org.elasticsearch.http.HttpHeadersValidationException.class, org.elasticsearch.http.HttpHeadersValidationException::new, 169, - TransportVersions.V_8_9_X + TransportVersion.minimumCompatible() ), ROLE_RESTRICTION_EXCEPTION( ElasticsearchRoleRestrictionException.class, ElasticsearchRoleRestrictionException::new, 170, - TransportVersions.V_8_9_X + TransportVersion.minimumCompatible() + ), + API_NOT_AVAILABLE_EXCEPTION( + ApiNotAvailableException.class, + ApiNotAvailableException::new, + 171, + TransportVersion.minimumCompatible() ), - API_NOT_AVAILABLE_EXCEPTION(ApiNotAvailableException.class, ApiNotAvailableException::new, 171, TransportVersions.V_8_11_X), RECOVERY_COMMIT_TOO_NEW_EXCEPTION( RecoveryCommitTooNewException.class, RecoveryCommitTooNewException::new, 172, - TransportVersions.V_8_11_X + TransportVersion.minimumCompatible() ), TOO_MANY_SCROLL_CONTEXTS_NEW_EXCEPTION( TooManyScrollContextsException.class, TooManyScrollContextsException::new, 173, - TransportVersions.V_8_12_0 + TransportVersion.minimumCompatible() ), INVALID_BUCKET_PATH_EXCEPTION( AggregationExecutionException.InvalidPath.class, AggregationExecutionException.InvalidPath::new, 174, - TransportVersions.V_8_12_0 + TransportVersion.minimumCompatible() ), MISSED_INDICES_UPDATE_EXCEPTION( AutoscalingMissedIndicesUpdateException.class, AutoscalingMissedIndicesUpdateException::new, 175, - TransportVersions.V_8_12_0 + TransportVersion.minimumCompatible() + ), + SEARCH_TIMEOUT_EXCEPTION(SearchTimeoutException.class, SearchTimeoutException::new, 176, TransportVersion.minimumCompatible()), + INGEST_GRAPH_STRUCTURE_EXCEPTION( + GraphStructureException.class, + GraphStructureException::new, + 177, + TransportVersion.minimumCompatible() ), - SEARCH_TIMEOUT_EXCEPTION(SearchTimeoutException.class, SearchTimeoutException::new, 176, TransportVersions.V_8_13_0), - INGEST_GRAPH_STRUCTURE_EXCEPTION(GraphStructureException.class, GraphStructureException::new, 177, TransportVersions.V_8_13_0), FAILURE_INDEX_NOT_SUPPORTED_EXCEPTION( FailureIndexNotSupportedException.class, FailureIndexNotSupportedException::new, 178, - TransportVersions.V_8_14_0 + TransportVersion.minimumCompatible() ), NOT_PERSISTENT_TASK_NODE_EXCEPTION( NotPersistentTaskNodeException.class, NotPersistentTaskNodeException::new, 179, - TransportVersions.V_8_14_0 + TransportVersion.minimumCompatible() ), PERSISTENT_TASK_NODE_NOT_ASSIGNED_EXCEPTION( PersistentTaskNodeNotAssignedException.class, PersistentTaskNodeNotAssignedException::new, 180, - TransportVersions.V_8_14_0 + TransportVersion.minimumCompatible() ), RESOURCE_ALREADY_UPLOADED_EXCEPTION( ResourceAlreadyUploadedException.class, ResourceAlreadyUploadedException::new, 181, - TransportVersions.V_8_15_0 + TransportVersion.minimumCompatible() ), INGEST_PIPELINE_EXCEPTION( org.elasticsearch.ingest.IngestPipelineException.class, org.elasticsearch.ingest.IngestPipelineException::new, 182, - TransportVersions.V_8_16_0 + TransportVersion.minimumCompatible() ), INDEX_RESPONSE_WRAPPER_EXCEPTION( IndexDocFailureStoreStatus.ExceptionWithFailureStoreStatus.class, IndexDocFailureStoreStatus.ExceptionWithFailureStoreStatus::new, 183, - TransportVersions.V_8_16_0 - ), - REMOTE_EXCEPTION( - RemoteException.class, - RemoteException::new, - 184, - TransportVersions.REMOTE_EXCEPTION, - TransportVersions.REMOTE_EXCEPTION_8_19 + TransportVersion.minimumCompatible() ), + REMOTE_EXCEPTION(RemoteException.class, RemoteException::new, 184, TransportVersion.minimumCompatible()), NO_MATCHING_PROJECT_EXCEPTION( NoMatchingProjectException.class, NoMatchingProjectException::new, @@ -2035,23 +2046,20 @@ private enum ElasticsearchExceptionHandle { final Class exceptionClass; final CheckedFunction constructor; final int id; - private final TransportVersion versionAdded; - private final TransportVersion[] patchVersions; + private final TransportVersion minimumCompatible; ElasticsearchExceptionHandle( Class exceptionClass, CheckedFunction constructor, int id, - TransportVersion versionAdded, - TransportVersion... patchVersions + TransportVersion minimumCompatible ) { // We need the exceptionClass because you can't dig it out of the constructor reliably. this.exceptionClass = exceptionClass; this.constructor = constructor; this.id = id; - this.versionAdded = versionAdded; - this.patchVersions = patchVersions; + this.minimumCompatible = minimumCompatible; } } diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 2f7fb3660446f..1b70407f89639 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -238,7 +238,7 @@ public TestException(StreamInput in) throws IOException { } private T serialize(T exception) throws IOException { - return serialize(exception, TransportVersionUtils.randomVersion(random())); + return serialize(exception, TransportVersionUtils.randomCompatibleVersion(random())); } private T serialize(T exception, TransportVersion version) throws IOException { @@ -366,7 +366,7 @@ public void testSearchContextMissingException() throws IOException { public void testCircuitBreakingException() throws IOException { CircuitBreakingException ex = serialize( new CircuitBreakingException("Too large", 0, 100, CircuitBreaker.Durability.TRANSIENT), - TransportVersions.V_8_0_0 + TransportVersionUtils.randomCompatibleVersion(random()) ); assertEquals("Too large", ex.getMessage()); assertEquals(100, ex.getByteLimit());