diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index dbbe98633ae..483b732fe07 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -40,6 +40,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import static java.util.Collections.unmodifiableMap; import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_UUID_NA_VALUE; /** @@ -206,7 +207,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte * @param exType the exception type to look for * @return whether there is a nested exception of the specified type */ - public boolean contains(Class exType) { + public boolean contains(Class exType) { if (exType == null) { return false; } @@ -470,158 +471,288 @@ public class ElasticsearchException extends RuntimeException implements ToXConte return throwable; } + /** + * This is the list of Exceptions Elasticsearch can throw over the wire or save into a corruption marker. Each value in the enum is a + * single exception tying the Class to an id for use of the encode side and the id back to a constructor for use on the decode side. As + * such its ok if the exceptions to change names so long as their constructor can still read the exception. Each exception is listed + * in id order below. If you want to remove an exception leave a tombstone comment and mark the id as null in + * ExceptionSerializationTests.testIds.ids. + */ enum ElasticsearchExceptionHandle { - // each exception gets an assigned id that must never change. While the exception name can - // change due to refactorings etc. like renaming we have to keep the ordinal <--> class mapping - // to deserialize the exception coming from another node or from an corruption marker on - // a corrupted index. - // these exceptions can be ordered and removed, but (repeating) the ids must never change - // to remove an exception, remove the enum value below, and mark the id as null in ExceptionSerializationTests.testIds.ids - INDEX_SHARD_SNAPSHOT_FAILED_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException::new, 0), - DFS_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, org.elasticsearch.search.dfs.DfsPhaseExecutionException::new, 1), - EXECUTION_CANCELLED_EXCEPTION(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, 2), - MASTER_NOT_DISCOVERED_EXCEPTION(org.elasticsearch.discovery.MasterNotDiscoveredException.class, org.elasticsearch.discovery.MasterNotDiscoveredException::new, 3), - ELASTICSEARCH_SECURITY_EXCEPTION(org.elasticsearch.ElasticsearchSecurityException.class, org.elasticsearch.ElasticsearchSecurityException::new, 4), - INDEX_SHARD_RESTORE_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, org.elasticsearch.index.snapshots.IndexShardRestoreException::new, 5), - INDEX_CLOSED_EXCEPTION(org.elasticsearch.indices.IndexClosedException.class, org.elasticsearch.indices.IndexClosedException::new, 6), - BIND_HTTP_EXCEPTION(org.elasticsearch.http.BindHttpException.class, org.elasticsearch.http.BindHttpException::new, 7), - REDUCE_SEARCH_PHASE_EXCEPTION(org.elasticsearch.action.search.ReduceSearchPhaseException.class, org.elasticsearch.action.search.ReduceSearchPhaseException::new, 8), - NODE_CLOSED_EXCEPTION(org.elasticsearch.node.NodeClosedException.class, org.elasticsearch.node.NodeClosedException::new, 9), - SNAPSHOT_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, org.elasticsearch.index.engine.SnapshotFailedEngineException::new, 10), - SHARD_NOT_FOUND_EXCEPTION(org.elasticsearch.index.shard.ShardNotFoundException.class, org.elasticsearch.index.shard.ShardNotFoundException::new, 11), - CONNECT_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ConnectTransportException.class, org.elasticsearch.transport.ConnectTransportException::new, 12), - NOT_SERIALIZABLE_TRANSPORT_EXCEPTION(org.elasticsearch.transport.NotSerializableTransportException.class, org.elasticsearch.transport.NotSerializableTransportException::new, 13), - RESPONSE_HANDLER_FAILURE_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, org.elasticsearch.transport.ResponseHandlerFailureTransportException::new, 14), - INDEX_CREATION_EXCEPTION(org.elasticsearch.indices.IndexCreationException.class, org.elasticsearch.indices.IndexCreationException::new, 15), - INDEX_NOT_FOUND_EXCEPTION(org.elasticsearch.index.IndexNotFoundException.class, org.elasticsearch.index.IndexNotFoundException::new, 16), - ILLEGAL_SHARD_ROUTING_STATE_EXCEPTION(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, org.elasticsearch.cluster.routing.IllegalShardRoutingStateException::new, 17), - BROADCAST_SHARD_OPERATION_FAILED_EXCEPTION(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException::new, 18), - RESOURCE_NOT_FOUND_EXCEPTION(org.elasticsearch.ResourceNotFoundException.class, org.elasticsearch.ResourceNotFoundException::new, 19), - ACTION_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ActionTransportException.class, org.elasticsearch.transport.ActionTransportException::new, 20), - ELASTICSEARCH_GENERATION_EXCEPTION(org.elasticsearch.ElasticsearchGenerationException.class, org.elasticsearch.ElasticsearchGenerationException::new, 21), + INDEX_SHARD_SNAPSHOT_FAILED_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, + org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException::new, 0), + DFS_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, + org.elasticsearch.search.dfs.DfsPhaseExecutionException::new, 1), + EXECUTION_CANCELLED_EXCEPTION(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, + org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, 2), + MASTER_NOT_DISCOVERED_EXCEPTION(org.elasticsearch.discovery.MasterNotDiscoveredException.class, + org.elasticsearch.discovery.MasterNotDiscoveredException::new, 3), + ELASTICSEARCH_SECURITY_EXCEPTION(org.elasticsearch.ElasticsearchSecurityException.class, + org.elasticsearch.ElasticsearchSecurityException::new, 4), + INDEX_SHARD_RESTORE_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, + org.elasticsearch.index.snapshots.IndexShardRestoreException::new, 5), + INDEX_CLOSED_EXCEPTION(org.elasticsearch.indices.IndexClosedException.class, + org.elasticsearch.indices.IndexClosedException::new, 6), + BIND_HTTP_EXCEPTION(org.elasticsearch.http.BindHttpException.class, + org.elasticsearch.http.BindHttpException::new, 7), + REDUCE_SEARCH_PHASE_EXCEPTION(org.elasticsearch.action.search.ReduceSearchPhaseException.class, + org.elasticsearch.action.search.ReduceSearchPhaseException::new, 8), + NODE_CLOSED_EXCEPTION(org.elasticsearch.node.NodeClosedException.class, + org.elasticsearch.node.NodeClosedException::new, 9), + SNAPSHOT_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, + org.elasticsearch.index.engine.SnapshotFailedEngineException::new, 10), + SHARD_NOT_FOUND_EXCEPTION(org.elasticsearch.index.shard.ShardNotFoundException.class, + org.elasticsearch.index.shard.ShardNotFoundException::new, 11), + CONNECT_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ConnectTransportException.class, + org.elasticsearch.transport.ConnectTransportException::new, 12), + NOT_SERIALIZABLE_TRANSPORT_EXCEPTION(org.elasticsearch.transport.NotSerializableTransportException.class, + org.elasticsearch.transport.NotSerializableTransportException::new, 13), + RESPONSE_HANDLER_FAILURE_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, + org.elasticsearch.transport.ResponseHandlerFailureTransportException::new, 14), + INDEX_CREATION_EXCEPTION(org.elasticsearch.indices.IndexCreationException.class, + org.elasticsearch.indices.IndexCreationException::new, 15), + INDEX_NOT_FOUND_EXCEPTION(org.elasticsearch.index.IndexNotFoundException.class, + org.elasticsearch.index.IndexNotFoundException::new, 16), + ILLEGAL_SHARD_ROUTING_STATE_EXCEPTION(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, + org.elasticsearch.cluster.routing.IllegalShardRoutingStateException::new, 17), + BROADCAST_SHARD_OPERATION_FAILED_EXCEPTION(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, + org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException::new, 18), + RESOURCE_NOT_FOUND_EXCEPTION(org.elasticsearch.ResourceNotFoundException.class, + org.elasticsearch.ResourceNotFoundException::new, 19), + ACTION_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ActionTransportException.class, + org.elasticsearch.transport.ActionTransportException::new, 20), + ELASTICSEARCH_GENERATION_EXCEPTION(org.elasticsearch.ElasticsearchGenerationException.class, + org.elasticsearch.ElasticsearchGenerationException::new, 21), // 22 was CreateFailedEngineException - INDEX_SHARD_STARTED_EXCEPTION(org.elasticsearch.index.shard.IndexShardStartedException.class, org.elasticsearch.index.shard.IndexShardStartedException::new, 23), - SEARCH_CONTEXT_MISSING_EXCEPTION(org.elasticsearch.search.SearchContextMissingException.class, org.elasticsearch.search.SearchContextMissingException::new, 24), + INDEX_SHARD_STARTED_EXCEPTION(org.elasticsearch.index.shard.IndexShardStartedException.class, + org.elasticsearch.index.shard.IndexShardStartedException::new, 23), + SEARCH_CONTEXT_MISSING_EXCEPTION(org.elasticsearch.search.SearchContextMissingException.class, + org.elasticsearch.search.SearchContextMissingException::new, 24), SCRIPT_EXCEPTION(org.elasticsearch.script.ScriptException.class, org.elasticsearch.script.ScriptException::new, 25), - BATCH_OPERATION_EXCEPTION(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException::new, 26), - SNAPSHOT_CREATION_EXCEPTION(org.elasticsearch.snapshots.SnapshotCreationException.class, org.elasticsearch.snapshots.SnapshotCreationException::new, 27), - DELETE_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.DeleteFailedEngineException.class, org.elasticsearch.index.engine.DeleteFailedEngineException::new, 28), - DOCUMENT_MISSING_EXCEPTION(org.elasticsearch.index.engine.DocumentMissingException.class, org.elasticsearch.index.engine.DocumentMissingException::new, 29), - SNAPSHOT_EXCEPTION(org.elasticsearch.snapshots.SnapshotException.class, org.elasticsearch.snapshots.SnapshotException::new, 30), - INVALID_ALIAS_NAME_EXCEPTION(org.elasticsearch.indices.InvalidAliasNameException.class, org.elasticsearch.indices.InvalidAliasNameException::new, 31), - INVALID_INDEX_NAME_EXCEPTION(org.elasticsearch.indices.InvalidIndexNameException.class, org.elasticsearch.indices.InvalidIndexNameException::new, 32), - INDEX_PRIMARY_SHARD_NOT_ALLOCATED_EXCEPTION(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException::new, 33), - TRANSPORT_EXCEPTION(org.elasticsearch.transport.TransportException.class, org.elasticsearch.transport.TransportException::new, 34), - ELASTICSEARCH_PARSE_EXCEPTION(org.elasticsearch.ElasticsearchParseException.class, org.elasticsearch.ElasticsearchParseException::new, 35), - SEARCH_EXCEPTION(org.elasticsearch.search.SearchException.class, org.elasticsearch.search.SearchException::new, 36), - MAPPER_EXCEPTION(org.elasticsearch.index.mapper.MapperException.class, org.elasticsearch.index.mapper.MapperException::new, 37), - INVALID_TYPE_NAME_EXCEPTION(org.elasticsearch.indices.InvalidTypeNameException.class, org.elasticsearch.indices.InvalidTypeNameException::new, 38), - SNAPSHOT_RESTORE_EXCEPTION(org.elasticsearch.snapshots.SnapshotRestoreException.class, org.elasticsearch.snapshots.SnapshotRestoreException::new, 39), + BATCH_OPERATION_EXCEPTION(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, + org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException::new, 26), + SNAPSHOT_CREATION_EXCEPTION(org.elasticsearch.snapshots.SnapshotCreationException.class, + org.elasticsearch.snapshots.SnapshotCreationException::new, 27), + DELETE_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.DeleteFailedEngineException.class, + org.elasticsearch.index.engine.DeleteFailedEngineException::new, 28), + DOCUMENT_MISSING_EXCEPTION(org.elasticsearch.index.engine.DocumentMissingException.class, + org.elasticsearch.index.engine.DocumentMissingException::new, 29), + SNAPSHOT_EXCEPTION(org.elasticsearch.snapshots.SnapshotException.class, + org.elasticsearch.snapshots.SnapshotException::new, 30), + INVALID_ALIAS_NAME_EXCEPTION(org.elasticsearch.indices.InvalidAliasNameException.class, + org.elasticsearch.indices.InvalidAliasNameException::new, 31), + INVALID_INDEX_NAME_EXCEPTION(org.elasticsearch.indices.InvalidIndexNameException.class, + org.elasticsearch.indices.InvalidIndexNameException::new, 32), + INDEX_PRIMARY_SHARD_NOT_ALLOCATED_EXCEPTION(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, + org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException::new, 33), + TRANSPORT_EXCEPTION(org.elasticsearch.transport.TransportException.class, + org.elasticsearch.transport.TransportException::new, 34), + ELASTICSEARCH_PARSE_EXCEPTION(org.elasticsearch.ElasticsearchParseException.class, + org.elasticsearch.ElasticsearchParseException::new, 35), + SEARCH_EXCEPTION(org.elasticsearch.search.SearchException.class, + org.elasticsearch.search.SearchException::new, 36), + MAPPER_EXCEPTION(org.elasticsearch.index.mapper.MapperException.class, + org.elasticsearch.index.mapper.MapperException::new, 37), + INVALID_TYPE_NAME_EXCEPTION(org.elasticsearch.indices.InvalidTypeNameException.class, + org.elasticsearch.indices.InvalidTypeNameException::new, 38), + SNAPSHOT_RESTORE_EXCEPTION(org.elasticsearch.snapshots.SnapshotRestoreException.class, + org.elasticsearch.snapshots.SnapshotRestoreException::new, 39), PARSING_EXCEPTION(org.elasticsearch.common.ParsingException.class, org.elasticsearch.common.ParsingException::new, 40), - INDEX_SHARD_CLOSED_EXCEPTION(org.elasticsearch.index.shard.IndexShardClosedException.class, org.elasticsearch.index.shard.IndexShardClosedException::new, 41), - RECOVER_FILES_RECOVERY_EXCEPTION(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, org.elasticsearch.indices.recovery.RecoverFilesRecoveryException::new, 42), - TRUNCATED_TRANSLOG_EXCEPTION(org.elasticsearch.index.translog.TruncatedTranslogException.class, org.elasticsearch.index.translog.TruncatedTranslogException::new, 43), - RECOVERY_FAILED_EXCEPTION(org.elasticsearch.indices.recovery.RecoveryFailedException.class, org.elasticsearch.indices.recovery.RecoveryFailedException::new, 44), - INDEX_SHARD_RELOCATED_EXCEPTION(org.elasticsearch.index.shard.IndexShardRelocatedException.class, org.elasticsearch.index.shard.IndexShardRelocatedException::new, 45), - NODE_SHOULD_NOT_CONNECT_EXCEPTION(org.elasticsearch.transport.NodeShouldNotConnectException.class, org.elasticsearch.transport.NodeShouldNotConnectException::new, 46), - INDEX_TEMPLATE_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, org.elasticsearch.indices.IndexTemplateAlreadyExistsException::new, 47), - TRANSLOG_CORRUPTED_EXCEPTION(org.elasticsearch.index.translog.TranslogCorruptedException.class, org.elasticsearch.index.translog.TranslogCorruptedException::new, 48), - CLUSTER_BLOCK_EXCEPTION(org.elasticsearch.cluster.block.ClusterBlockException.class, org.elasticsearch.cluster.block.ClusterBlockException::new, 49), - FETCH_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, org.elasticsearch.search.fetch.FetchPhaseExecutionException::new, 50), - INDEX_SHARD_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.index.IndexShardAlreadyExistsException.class, org.elasticsearch.index.IndexShardAlreadyExistsException::new, 51), - VERSION_CONFLICT_ENGINE_EXCEPTION(org.elasticsearch.index.engine.VersionConflictEngineException.class, org.elasticsearch.index.engine.VersionConflictEngineException::new, 52), + INDEX_SHARD_CLOSED_EXCEPTION(org.elasticsearch.index.shard.IndexShardClosedException.class, + org.elasticsearch.index.shard.IndexShardClosedException::new, 41), + RECOVER_FILES_RECOVERY_EXCEPTION(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, + org.elasticsearch.indices.recovery.RecoverFilesRecoveryException::new, 42), + TRUNCATED_TRANSLOG_EXCEPTION(org.elasticsearch.index.translog.TruncatedTranslogException.class, + org.elasticsearch.index.translog.TruncatedTranslogException::new, 43), + RECOVERY_FAILED_EXCEPTION(org.elasticsearch.indices.recovery.RecoveryFailedException.class, + org.elasticsearch.indices.recovery.RecoveryFailedException::new, 44), + INDEX_SHARD_RELOCATED_EXCEPTION(org.elasticsearch.index.shard.IndexShardRelocatedException.class, + org.elasticsearch.index.shard.IndexShardRelocatedException::new, 45), + NODE_SHOULD_NOT_CONNECT_EXCEPTION(org.elasticsearch.transport.NodeShouldNotConnectException.class, + org.elasticsearch.transport.NodeShouldNotConnectException::new, 46), + INDEX_TEMPLATE_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, + org.elasticsearch.indices.IndexTemplateAlreadyExistsException::new, 47), + TRANSLOG_CORRUPTED_EXCEPTION(org.elasticsearch.index.translog.TranslogCorruptedException.class, + org.elasticsearch.index.translog.TranslogCorruptedException::new, 48), + CLUSTER_BLOCK_EXCEPTION(org.elasticsearch.cluster.block.ClusterBlockException.class, + org.elasticsearch.cluster.block.ClusterBlockException::new, 49), + FETCH_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, + org.elasticsearch.search.fetch.FetchPhaseExecutionException::new, 50), + INDEX_SHARD_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.index.IndexShardAlreadyExistsException.class, + org.elasticsearch.index.IndexShardAlreadyExistsException::new, 51), + VERSION_CONFLICT_ENGINE_EXCEPTION(org.elasticsearch.index.engine.VersionConflictEngineException.class, + org.elasticsearch.index.engine.VersionConflictEngineException::new, 52), ENGINE_EXCEPTION(org.elasticsearch.index.engine.EngineException.class, org.elasticsearch.index.engine.EngineException::new, 53), // 54 was DocumentAlreadyExistsException, which is superseded by VersionConflictEngineException NO_SUCH_NODE_EXCEPTION(org.elasticsearch.action.NoSuchNodeException.class, org.elasticsearch.action.NoSuchNodeException::new, 55), - SETTINGS_EXCEPTION(org.elasticsearch.common.settings.SettingsException.class, org.elasticsearch.common.settings.SettingsException::new, 56), - INDEX_TEMPLATE_MISSING_EXCEPTION(org.elasticsearch.indices.IndexTemplateMissingException.class, org.elasticsearch.indices.IndexTemplateMissingException::new, 57), - SEND_REQUEST_TRANSPORT_EXCEPTION(org.elasticsearch.transport.SendRequestTransportException.class, org.elasticsearch.transport.SendRequestTransportException::new, 58), - ES_REJECTED_EXECUTION_EXCEPTION(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, org.elasticsearch.common.util.concurrent.EsRejectedExecutionException::new, 59), - EARLY_TERMINATION_EXCEPTION(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, org.elasticsearch.common.lucene.Lucene.EarlyTerminationException::new, 60), - ROUTING_VALIDATION_EXCEPTION(org.elasticsearch.cluster.routing.RoutingValidationException.class, org.elasticsearch.cluster.routing.RoutingValidationException::new, 61), - NOT_SERIALIZABLE_EXCEPTION_WRAPPER(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper::new, 62), - ALIAS_FILTER_PARSING_EXCEPTION(org.elasticsearch.indices.AliasFilterParsingException.class, org.elasticsearch.indices.AliasFilterParsingException::new, 63), + SETTINGS_EXCEPTION(org.elasticsearch.common.settings.SettingsException.class, + org.elasticsearch.common.settings.SettingsException::new, 56), + INDEX_TEMPLATE_MISSING_EXCEPTION(org.elasticsearch.indices.IndexTemplateMissingException.class, + org.elasticsearch.indices.IndexTemplateMissingException::new, 57), + SEND_REQUEST_TRANSPORT_EXCEPTION(org.elasticsearch.transport.SendRequestTransportException.class, + org.elasticsearch.transport.SendRequestTransportException::new, 58), + ES_REJECTED_EXECUTION_EXCEPTION(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, + org.elasticsearch.common.util.concurrent.EsRejectedExecutionException::new, 59), + EARLY_TERMINATION_EXCEPTION(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, + org.elasticsearch.common.lucene.Lucene.EarlyTerminationException::new, 60), + ROUTING_VALIDATION_EXCEPTION(org.elasticsearch.cluster.routing.RoutingValidationException.class, + org.elasticsearch.cluster.routing.RoutingValidationException::new, 61), + NOT_SERIALIZABLE_EXCEPTION_WRAPPER(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, + org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper::new, 62), + ALIAS_FILTER_PARSING_EXCEPTION(org.elasticsearch.indices.AliasFilterParsingException.class, + org.elasticsearch.indices.AliasFilterParsingException::new, 63), // 64 was DeleteByQueryFailedEngineException, which was removed in 3.0 GATEWAY_EXCEPTION(org.elasticsearch.gateway.GatewayException.class, org.elasticsearch.gateway.GatewayException::new, 65), - INDEX_SHARD_NOT_RECOVERING_EXCEPTION(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, org.elasticsearch.index.shard.IndexShardNotRecoveringException::new, 66), + INDEX_SHARD_NOT_RECOVERING_EXCEPTION(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, + org.elasticsearch.index.shard.IndexShardNotRecoveringException::new, 66), HTTP_EXCEPTION(org.elasticsearch.http.HttpException.class, org.elasticsearch.http.HttpException::new, 67), - ELASTICSEARCH_EXCEPTION(org.elasticsearch.ElasticsearchException.class, org.elasticsearch.ElasticsearchException::new, 68), - SNAPSHOT_MISSING_EXCEPTION(org.elasticsearch.snapshots.SnapshotMissingException.class, org.elasticsearch.snapshots.SnapshotMissingException::new, 69), - PRIMARY_MISSING_ACTION_EXCEPTION(org.elasticsearch.action.PrimaryMissingActionException.class, org.elasticsearch.action.PrimaryMissingActionException::new, 70), + ELASTICSEARCH_EXCEPTION(org.elasticsearch.ElasticsearchException.class, + org.elasticsearch.ElasticsearchException::new, 68), + SNAPSHOT_MISSING_EXCEPTION(org.elasticsearch.snapshots.SnapshotMissingException.class, + org.elasticsearch.snapshots.SnapshotMissingException::new, 69), + PRIMARY_MISSING_ACTION_EXCEPTION(org.elasticsearch.action.PrimaryMissingActionException.class, + org.elasticsearch.action.PrimaryMissingActionException::new, 70), FAILED_NODE_EXCEPTION(org.elasticsearch.action.FailedNodeException.class, org.elasticsearch.action.FailedNodeException::new, 71), SEARCH_PARSE_EXCEPTION(org.elasticsearch.search.SearchParseException.class, org.elasticsearch.search.SearchParseException::new, 72), - CONCURRENT_SNAPSHOT_EXECUTION_EXCEPTION(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException::new, 73), - BLOB_STORE_EXCEPTION(org.elasticsearch.common.blobstore.BlobStoreException.class, org.elasticsearch.common.blobstore.BlobStoreException::new, 74), - INCOMPATIBLE_CLUSTER_STATE_VERSION_EXCEPTION(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, org.elasticsearch.cluster.IncompatibleClusterStateVersionException::new, 75), - RECOVERY_ENGINE_EXCEPTION(org.elasticsearch.index.engine.RecoveryEngineException.class, org.elasticsearch.index.engine.RecoveryEngineException::new, 76), - UNCATEGORIZED_EXECUTION_EXCEPTION(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, org.elasticsearch.common.util.concurrent.UncategorizedExecutionException::new, 77), - TIMESTAMP_PARSING_EXCEPTION(org.elasticsearch.action.TimestampParsingException.class, org.elasticsearch.action.TimestampParsingException::new, 78), - ROUTING_MISSING_EXCEPTION(org.elasticsearch.action.RoutingMissingException.class, org.elasticsearch.action.RoutingMissingException::new, 79), - INDEX_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.IndexFailedEngineException.class, org.elasticsearch.index.engine.IndexFailedEngineException::new, 80), - INDEX_SHARD_RESTORE_FAILED_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, org.elasticsearch.index.snapshots.IndexShardRestoreFailedException::new, 81), - REPOSITORY_EXCEPTION(org.elasticsearch.repositories.RepositoryException.class, org.elasticsearch.repositories.RepositoryException::new, 82), - RECEIVE_TIMEOUT_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, org.elasticsearch.transport.ReceiveTimeoutTransportException::new, 83), - NODE_DISCONNECTED_EXCEPTION(org.elasticsearch.transport.NodeDisconnectedException.class, org.elasticsearch.transport.NodeDisconnectedException::new, 84), - ALREADY_EXPIRED_EXCEPTION(org.elasticsearch.index.AlreadyExpiredException.class, org.elasticsearch.index.AlreadyExpiredException::new, 85), - AGGREGATION_EXECUTION_EXCEPTION(org.elasticsearch.search.aggregations.AggregationExecutionException.class, org.elasticsearch.search.aggregations.AggregationExecutionException::new, 86), + CONCURRENT_SNAPSHOT_EXECUTION_EXCEPTION(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, + org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException::new, 73), + BLOB_STORE_EXCEPTION(org.elasticsearch.common.blobstore.BlobStoreException.class, + org.elasticsearch.common.blobstore.BlobStoreException::new, 74), + INCOMPATIBLE_CLUSTER_STATE_VERSION_EXCEPTION(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, + org.elasticsearch.cluster.IncompatibleClusterStateVersionException::new, 75), + RECOVERY_ENGINE_EXCEPTION(org.elasticsearch.index.engine.RecoveryEngineException.class, + org.elasticsearch.index.engine.RecoveryEngineException::new, 76), + UNCATEGORIZED_EXECUTION_EXCEPTION(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, + org.elasticsearch.common.util.concurrent.UncategorizedExecutionException::new, 77), + TIMESTAMP_PARSING_EXCEPTION(org.elasticsearch.action.TimestampParsingException.class, + org.elasticsearch.action.TimestampParsingException::new, 78), + ROUTING_MISSING_EXCEPTION(org.elasticsearch.action.RoutingMissingException.class, + org.elasticsearch.action.RoutingMissingException::new, 79), + INDEX_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.IndexFailedEngineException.class, + org.elasticsearch.index.engine.IndexFailedEngineException::new, 80), + INDEX_SHARD_RESTORE_FAILED_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, + org.elasticsearch.index.snapshots.IndexShardRestoreFailedException::new, 81), + REPOSITORY_EXCEPTION(org.elasticsearch.repositories.RepositoryException.class, + org.elasticsearch.repositories.RepositoryException::new, 82), + RECEIVE_TIMEOUT_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, + org.elasticsearch.transport.ReceiveTimeoutTransportException::new, 83), + NODE_DISCONNECTED_EXCEPTION(org.elasticsearch.transport.NodeDisconnectedException.class, + org.elasticsearch.transport.NodeDisconnectedException::new, 84), + ALREADY_EXPIRED_EXCEPTION(org.elasticsearch.index.AlreadyExpiredException.class, + org.elasticsearch.index.AlreadyExpiredException::new, 85), + AGGREGATION_EXECUTION_EXCEPTION(org.elasticsearch.search.aggregations.AggregationExecutionException.class, + org.elasticsearch.search.aggregations.AggregationExecutionException::new, 86), // 87 used to be for MergeMappingException - INVALID_INDEX_TEMPLATE_EXCEPTION(org.elasticsearch.indices.InvalidIndexTemplateException.class, org.elasticsearch.indices.InvalidIndexTemplateException::new, 88), - PERCOLATE_EXCEPTION(org.elasticsearch.percolator.PercolateException.class, org.elasticsearch.percolator.PercolateException::new, 89), - REFRESH_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.RefreshFailedEngineException.class, org.elasticsearch.index.engine.RefreshFailedEngineException::new, 90), - AGGREGATION_INITIALIZATION_EXCEPTION(org.elasticsearch.search.aggregations.AggregationInitializationException.class, org.elasticsearch.search.aggregations.AggregationInitializationException::new, 91), - DELAY_RECOVERY_EXCEPTION(org.elasticsearch.indices.recovery.DelayRecoveryException.class, org.elasticsearch.indices.recovery.DelayRecoveryException::new, 92), + INVALID_INDEX_TEMPLATE_EXCEPTION(org.elasticsearch.indices.InvalidIndexTemplateException.class, + org.elasticsearch.indices.InvalidIndexTemplateException::new, 88), + PERCOLATE_EXCEPTION(org.elasticsearch.percolator.PercolateException.class, + org.elasticsearch.percolator.PercolateException::new, 89), + REFRESH_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.RefreshFailedEngineException.class, + org.elasticsearch.index.engine.RefreshFailedEngineException::new, 90), + AGGREGATION_INITIALIZATION_EXCEPTION(org.elasticsearch.search.aggregations.AggregationInitializationException.class, + org.elasticsearch.search.aggregations.AggregationInitializationException::new, 91), + DELAY_RECOVERY_EXCEPTION(org.elasticsearch.indices.recovery.DelayRecoveryException.class, + org.elasticsearch.indices.recovery.DelayRecoveryException::new, 92), // 93 used to be for IndexWarmerMissingException - NO_NODE_AVAILABLE_EXCEPTION(org.elasticsearch.client.transport.NoNodeAvailableException.class, org.elasticsearch.client.transport.NoNodeAvailableException::new, 94), - INVALID_SNAPSHOT_NAME_EXCEPTION(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, org.elasticsearch.snapshots.InvalidSnapshotNameException::new, 96), - ILLEGAL_INDEX_SHARD_STATE_EXCEPTION(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, org.elasticsearch.index.shard.IllegalIndexShardStateException::new, 97), - INDEX_SHARD_SNAPSHOT_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, org.elasticsearch.index.snapshots.IndexShardSnapshotException::new, 98), - INDEX_SHARD_NOT_STARTED_EXCEPTION(org.elasticsearch.index.shard.IndexShardNotStartedException.class, org.elasticsearch.index.shard.IndexShardNotStartedException::new, 99), - SEARCH_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.action.search.SearchPhaseExecutionException.class, org.elasticsearch.action.search.SearchPhaseExecutionException::new, 100), - ACTION_NOT_FOUND_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ActionNotFoundTransportException.class, org.elasticsearch.transport.ActionNotFoundTransportException::new, 101), - TRANSPORT_SERIALIZATION_EXCEPTION(org.elasticsearch.transport.TransportSerializationException.class, org.elasticsearch.transport.TransportSerializationException::new, 102), - REMOTE_TRANSPORT_EXCEPTION(org.elasticsearch.transport.RemoteTransportException.class, org.elasticsearch.transport.RemoteTransportException::new, 103), - ENGINE_CREATION_FAILURE_EXCEPTION(org.elasticsearch.index.engine.EngineCreationFailureException.class, org.elasticsearch.index.engine.EngineCreationFailureException::new, 104), - ROUTING_EXCEPTION(org.elasticsearch.cluster.routing.RoutingException.class, org.elasticsearch.cluster.routing.RoutingException::new, 105), - INDEX_SHARD_RECOVERY_EXCEPTION(org.elasticsearch.index.shard.IndexShardRecoveryException.class, org.elasticsearch.index.shard.IndexShardRecoveryException::new, 106), - REPOSITORY_MISSING_EXCEPTION(org.elasticsearch.repositories.RepositoryMissingException.class, org.elasticsearch.repositories.RepositoryMissingException::new, 107), - PERCOLATOR_EXCEPTION(org.elasticsearch.index.percolator.PercolatorException.class, org.elasticsearch.index.percolator.PercolatorException::new, 108), - DOCUMENT_SOURCE_MISSING_EXCEPTION(org.elasticsearch.index.engine.DocumentSourceMissingException.class, org.elasticsearch.index.engine.DocumentSourceMissingException::new, 109), - FLUSH_NOT_ALLOWED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, org.elasticsearch.index.engine.FlushNotAllowedEngineException::new, 110), - NO_CLASS_SETTINGS_EXCEPTION(org.elasticsearch.common.settings.NoClassSettingsException.class, org.elasticsearch.common.settings.NoClassSettingsException::new, 111), - BIND_TRANSPORT_EXCEPTION(org.elasticsearch.transport.BindTransportException.class, org.elasticsearch.transport.BindTransportException::new, 112), - ALIASES_NOT_FOUND_EXCEPTION(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException::new, 113), - INDEX_SHARD_RECOVERING_EXCEPTION(org.elasticsearch.index.shard.IndexShardRecoveringException.class, org.elasticsearch.index.shard.IndexShardRecoveringException::new, 114), - TRANSLOG_EXCEPTION(org.elasticsearch.index.translog.TranslogException.class, org.elasticsearch.index.translog.TranslogException::new, 115), - PROCESS_CLUSTER_EVENT_TIMEOUT_EXCEPTION(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException::new, 116), - RETRY_ON_PRIMARY_EXCEPTION(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException::new, 117), - ELASTICSEARCH_TIMEOUT_EXCEPTION(org.elasticsearch.ElasticsearchTimeoutException.class, org.elasticsearch.ElasticsearchTimeoutException::new, 118), - QUERY_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.query.QueryPhaseExecutionException.class, org.elasticsearch.search.query.QueryPhaseExecutionException::new, 119), - REPOSITORY_VERIFICATION_EXCEPTION(org.elasticsearch.repositories.RepositoryVerificationException.class, org.elasticsearch.repositories.RepositoryVerificationException::new, 120), - INVALID_AGGREGATION_PATH_EXCEPTION(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, org.elasticsearch.search.aggregations.InvalidAggregationPathException::new, 121), - INDEX_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.indices.IndexAlreadyExistsException.class, org.elasticsearch.indices.IndexAlreadyExistsException::new, 123), - SCRIPT_PARSE_EXCEPTION(org.elasticsearch.script.Script.ScriptParseException.class, org.elasticsearch.script.Script.ScriptParseException::new, 124), - HTTP_ON_TRANSPORT_EXCEPTION(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException::new, 125), - MAPPER_PARSING_EXCEPTION(org.elasticsearch.index.mapper.MapperParsingException.class, org.elasticsearch.index.mapper.MapperParsingException::new, 126), - SEARCH_CONTEXT_EXCEPTION(org.elasticsearch.search.SearchContextException.class, org.elasticsearch.search.SearchContextException::new, 127), - SEARCH_SOURCE_BUILDER_EXCEPTION(org.elasticsearch.search.builder.SearchSourceBuilderException.class, org.elasticsearch.search.builder.SearchSourceBuilderException::new, 128), - ENGINE_CLOSED_EXCEPTION(org.elasticsearch.index.engine.EngineClosedException.class, org.elasticsearch.index.engine.EngineClosedException::new, 129), - NO_SHARD_AVAILABLE_ACTION_EXCEPTION(org.elasticsearch.action.NoShardAvailableActionException.class, org.elasticsearch.action.NoShardAvailableActionException::new, 130), - UNAVAILABLE_SHARDS_EXCEPTION(org.elasticsearch.action.UnavailableShardsException.class, org.elasticsearch.action.UnavailableShardsException::new, 131), - FLUSH_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.FlushFailedEngineException.class, org.elasticsearch.index.engine.FlushFailedEngineException::new, 132), - CIRCUIT_BREAKING_EXCEPTION(org.elasticsearch.common.breaker.CircuitBreakingException.class, org.elasticsearch.common.breaker.CircuitBreakingException::new, 133), - NODE_NOT_CONNECTED_EXCEPTION(org.elasticsearch.transport.NodeNotConnectedException.class, org.elasticsearch.transport.NodeNotConnectedException::new, 134), - STRICT_DYNAMIC_MAPPING_EXCEPTION(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, org.elasticsearch.index.mapper.StrictDynamicMappingException::new, 135), - RETRY_ON_REPLICA_EXCEPTION(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException::new, 136), - TYPE_MISSING_EXCEPTION(org.elasticsearch.indices.TypeMissingException.class, org.elasticsearch.indices.TypeMissingException::new, 137), - FAILED_TO_COMMIT_CLUSTER_STATE_EXCEPTION(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException::new, 140), - QUERY_SHARD_EXCEPTION(org.elasticsearch.index.query.QueryShardException.class, org.elasticsearch.index.query.QueryShardException::new, 141), - NO_LONGER_PRIMARY_SHARD_EXCEPTION(ShardStateAction.NoLongerPrimaryShardException.class, ShardStateAction.NoLongerPrimaryShardException::new, 142); + NO_NODE_AVAILABLE_EXCEPTION(org.elasticsearch.client.transport.NoNodeAvailableException.class, + org.elasticsearch.client.transport.NoNodeAvailableException::new, 94), + INVALID_SNAPSHOT_NAME_EXCEPTION(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, + org.elasticsearch.snapshots.InvalidSnapshotNameException::new, 96), + ILLEGAL_INDEX_SHARD_STATE_EXCEPTION(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, + org.elasticsearch.index.shard.IllegalIndexShardStateException::new, 97), + INDEX_SHARD_SNAPSHOT_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, + org.elasticsearch.index.snapshots.IndexShardSnapshotException::new, 98), + INDEX_SHARD_NOT_STARTED_EXCEPTION(org.elasticsearch.index.shard.IndexShardNotStartedException.class, + org.elasticsearch.index.shard.IndexShardNotStartedException::new, 99), + SEARCH_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.action.search.SearchPhaseExecutionException.class, + org.elasticsearch.action.search.SearchPhaseExecutionException::new, 100), + ACTION_NOT_FOUND_TRANSPORT_EXCEPTION(org.elasticsearch.transport.ActionNotFoundTransportException.class, + org.elasticsearch.transport.ActionNotFoundTransportException::new, 101), + TRANSPORT_SERIALIZATION_EXCEPTION(org.elasticsearch.transport.TransportSerializationException.class, + org.elasticsearch.transport.TransportSerializationException::new, 102), + REMOTE_TRANSPORT_EXCEPTION(org.elasticsearch.transport.RemoteTransportException.class, + org.elasticsearch.transport.RemoteTransportException::new, 103), + ENGINE_CREATION_FAILURE_EXCEPTION(org.elasticsearch.index.engine.EngineCreationFailureException.class, + org.elasticsearch.index.engine.EngineCreationFailureException::new, 104), + ROUTING_EXCEPTION(org.elasticsearch.cluster.routing.RoutingException.class, + org.elasticsearch.cluster.routing.RoutingException::new, 105), + INDEX_SHARD_RECOVERY_EXCEPTION(org.elasticsearch.index.shard.IndexShardRecoveryException.class, + org.elasticsearch.index.shard.IndexShardRecoveryException::new, 106), + REPOSITORY_MISSING_EXCEPTION(org.elasticsearch.repositories.RepositoryMissingException.class, + org.elasticsearch.repositories.RepositoryMissingException::new, 107), + PERCOLATOR_EXCEPTION(org.elasticsearch.index.percolator.PercolatorException.class, + org.elasticsearch.index.percolator.PercolatorException::new, 108), + DOCUMENT_SOURCE_MISSING_EXCEPTION(org.elasticsearch.index.engine.DocumentSourceMissingException.class, + org.elasticsearch.index.engine.DocumentSourceMissingException::new, 109), + FLUSH_NOT_ALLOWED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, + org.elasticsearch.index.engine.FlushNotAllowedEngineException::new, 110), + NO_CLASS_SETTINGS_EXCEPTION(org.elasticsearch.common.settings.NoClassSettingsException.class, + org.elasticsearch.common.settings.NoClassSettingsException::new, 111), + BIND_TRANSPORT_EXCEPTION(org.elasticsearch.transport.BindTransportException.class, + org.elasticsearch.transport.BindTransportException::new, 112), + ALIASES_NOT_FOUND_EXCEPTION(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, + org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException::new, 113), + INDEX_SHARD_RECOVERING_EXCEPTION(org.elasticsearch.index.shard.IndexShardRecoveringException.class, + org.elasticsearch.index.shard.IndexShardRecoveringException::new, 114), + TRANSLOG_EXCEPTION(org.elasticsearch.index.translog.TranslogException.class, + org.elasticsearch.index.translog.TranslogException::new, 115), + PROCESS_CLUSTER_EVENT_TIMEOUT_EXCEPTION(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, + org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException::new, 116), + RETRY_ON_PRIMARY_EXCEPTION(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, + org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException::new, 117), + ELASTICSEARCH_TIMEOUT_EXCEPTION(org.elasticsearch.ElasticsearchTimeoutException.class, + org.elasticsearch.ElasticsearchTimeoutException::new, 118), + QUERY_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.query.QueryPhaseExecutionException.class, + org.elasticsearch.search.query.QueryPhaseExecutionException::new, 119), + REPOSITORY_VERIFICATION_EXCEPTION(org.elasticsearch.repositories.RepositoryVerificationException.class, + org.elasticsearch.repositories.RepositoryVerificationException::new, 120), + INVALID_AGGREGATION_PATH_EXCEPTION(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, + org.elasticsearch.search.aggregations.InvalidAggregationPathException::new, 121), + INDEX_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.indices.IndexAlreadyExistsException.class, + org.elasticsearch.indices.IndexAlreadyExistsException::new, 123), + SCRIPT_PARSE_EXCEPTION(org.elasticsearch.script.Script.ScriptParseException.class, + org.elasticsearch.script.Script.ScriptParseException::new, 124), + HTTP_ON_TRANSPORT_EXCEPTION(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, + org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException::new, 125), + MAPPER_PARSING_EXCEPTION(org.elasticsearch.index.mapper.MapperParsingException.class, + org.elasticsearch.index.mapper.MapperParsingException::new, 126), + SEARCH_CONTEXT_EXCEPTION(org.elasticsearch.search.SearchContextException.class, + org.elasticsearch.search.SearchContextException::new, 127), + SEARCH_SOURCE_BUILDER_EXCEPTION(org.elasticsearch.search.builder.SearchSourceBuilderException.class, + org.elasticsearch.search.builder.SearchSourceBuilderException::new, 128), + ENGINE_CLOSED_EXCEPTION(org.elasticsearch.index.engine.EngineClosedException.class, + org.elasticsearch.index.engine.EngineClosedException::new, 129), + NO_SHARD_AVAILABLE_ACTION_EXCEPTION(org.elasticsearch.action.NoShardAvailableActionException.class, + org.elasticsearch.action.NoShardAvailableActionException::new, 130), + UNAVAILABLE_SHARDS_EXCEPTION(org.elasticsearch.action.UnavailableShardsException.class, + org.elasticsearch.action.UnavailableShardsException::new, 131), + FLUSH_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.FlushFailedEngineException.class, + org.elasticsearch.index.engine.FlushFailedEngineException::new, 132), + CIRCUIT_BREAKING_EXCEPTION(org.elasticsearch.common.breaker.CircuitBreakingException.class, + org.elasticsearch.common.breaker.CircuitBreakingException::new, 133), + NODE_NOT_CONNECTED_EXCEPTION(org.elasticsearch.transport.NodeNotConnectedException.class, + org.elasticsearch.transport.NodeNotConnectedException::new, 134), + STRICT_DYNAMIC_MAPPING_EXCEPTION(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, + org.elasticsearch.index.mapper.StrictDynamicMappingException::new, 135), + RETRY_ON_REPLICA_EXCEPTION(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, + org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException::new, 136), + TYPE_MISSING_EXCEPTION(org.elasticsearch.indices.TypeMissingException.class, + org.elasticsearch.indices.TypeMissingException::new, 137), + FAILED_TO_COMMIT_CLUSTER_STATE_EXCEPTION(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, + org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException::new, 140), + QUERY_SHARD_EXCEPTION(org.elasticsearch.index.query.QueryShardException.class, + org.elasticsearch.index.query.QueryShardException::new, 141), + NO_LONGER_PRIMARY_SHARD_EXCEPTION(ShardStateAction.NoLongerPrimaryShardException.class, + ShardStateAction.NoLongerPrimaryShardException::new, 142); + final Class exceptionClass; final FunctionThatThrowsIOException constructor; final int id; - ElasticsearchExceptionHandle(Class exceptionClass, FunctionThatThrowsIOException constructor, int id) { + ElasticsearchExceptionHandle(Class exceptionClass, + FunctionThatThrowsIOException constructor, int id) { + // We need the exceptionClass because you can't dig it out of the constructor reliably. this.exceptionClass = exceptionClass; this.constructor = constructor; this.id = id; @@ -629,11 +760,10 @@ public class ElasticsearchException extends RuntimeException implements ToXConte } static { - final Map, ElasticsearchExceptionHandle> exceptions = Arrays.stream(ElasticsearchExceptionHandle.values()).collect(Collectors.toMap(e -> e.exceptionClass, e -> e)); - final Map> idToSupplier = Arrays.stream(ElasticsearchExceptionHandle.values()).collect(Collectors.toMap(e -> e.id, e -> e.constructor)); - - ID_TO_SUPPLIER = Collections.unmodifiableMap(idToSupplier); - CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE = Collections.unmodifiableMap(exceptions); + ID_TO_SUPPLIER = unmodifiableMap(Arrays + .stream(ElasticsearchExceptionHandle.values()).collect(Collectors.toMap(e -> e.id, e -> e.constructor))); + CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE = unmodifiableMap(Arrays + .stream(ElasticsearchExceptionHandle.values()).collect(Collectors.toMap(e -> e.exceptionClass, e -> e))); } public Index getIndex() { @@ -705,7 +835,8 @@ public class ElasticsearchException extends RuntimeException implements ToXConte builder.startArray(); for (ElasticsearchException rootCause : rootCauses) { builder.startObject(); - rootCause.toXContent(builder, new ToXContent.DelegatingMapParams(Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params)); + rootCause.toXContent(builder, new ToXContent.DelegatingMapParams( + Collections.singletonMap(ElasticsearchException.REST_EXCEPTION_SKIP_CAUSE, "true"), params)); builder.endObject(); } builder.endArray(); diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 0b693aed56b..30c960993bb 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -82,7 +82,6 @@ import org.elasticsearch.transport.ActionTransportException; import org.elasticsearch.transport.ConnectTransportException; import java.io.IOException; -import java.lang.reflect.Modifier; import java.net.URISyntaxException; import java.nio.file.AccessDeniedException; import java.nio.file.AtomicMoveNotSupportedException; @@ -103,6 +102,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import static java.lang.reflect.Modifier.isAbstract; +import static java.lang.reflect.Modifier.isInterface; import static java.util.Collections.singleton; import static org.hamcrest.Matchers.greaterThanOrEqualTo; @@ -110,12 +111,13 @@ public class ExceptionSerializationTests extends ESTestCase { public void testExceptionRegistration() throws ClassNotFoundException, IOException, URISyntaxException { - final Set notRegistered = new HashSet<>(); - final Set hasDedicatedWrite = new HashSet<>(); - final Set registered = new HashSet<>(); + final Set> notRegistered = new HashSet<>(); + final Set> hasDedicatedWrite = new HashSet<>(); + final Set> registered = new HashSet<>(); final String path = "/org/elasticsearch"; - final Path startPath = PathUtils.get(ElasticsearchException.class.getProtectionDomain().getCodeSource().getLocation().toURI()).resolve("org").resolve("elasticsearch"); - final Set ignore = Sets.newHashSet( + final Path startPath = PathUtils.get(ElasticsearchException.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .resolve("org").resolve("elasticsearch"); + final Set> ignore = Sets.newHashSet( org.elasticsearch.test.rest.parser.RestTestParseException.class, org.elasticsearch.test.rest.client.RestException.class, CancellableThreadsTests.CustomException.class, @@ -136,33 +138,41 @@ public class ExceptionSerializationTests extends ESTestCase { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + checkFile(file.getFileName().toString()); + return FileVisitResult.CONTINUE; + } + + private void checkFile(String filename) { + if (filename.endsWith(".class") == false) { + return; + } try { - String filename = file.getFileName().toString(); - if (filename.endsWith(".class")) { - Class clazz = loadClass(filename); - if (ignore.contains(clazz) == false) { - if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false && isEsException(clazz)) { - if (ElasticsearchException.isRegistered((Class) clazz) == false && ElasticsearchException.class.equals(clazz.getEnclosingClass()) == false) { - notRegistered.add(clazz); - } else if (ElasticsearchException.isRegistered((Class) clazz)) { - registered.add(clazz); - try { - if (clazz.getMethod("writeTo", StreamOutput.class) != null) { - hasDedicatedWrite.add(clazz); - } - } catch (Exception e) { - // fair enough - } - - } - } - } - - } + checkClass(loadClass(filename)); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } - return FileVisitResult.CONTINUE; + } + + private void checkClass(Class clazz) { + if (ignore.contains(clazz) || isAbstract(clazz.getModifiers()) || isInterface(clazz.getModifiers())) { + return; + } + if (isEsException(clazz) == false) { + return; + } + if (ElasticsearchException.isRegistered(clazz.asSubclass(Throwable.class)) == false + && ElasticsearchException.class.equals(clazz.getEnclosingClass()) == false) { + notRegistered.add(clazz); + } else if (ElasticsearchException.isRegistered(clazz.asSubclass(Throwable.class))) { + registered.add(clazz); + try { + if (clazz.getMethod("writeTo", StreamOutput.class) != null) { + hasDedicatedWrite.add(clazz); + } + } catch (Exception e) { + // fair enough + } + } } private boolean isEsException(Class clazz) { @@ -218,7 +228,8 @@ public class ExceptionSerializationTests extends ESTestCase { public void testIllegalShardRoutingStateException() throws IOException { final ShardRouting routing = TestShardRouting.newShardRouting("test", 0, "xyz", "def", false, ShardRoutingState.STARTED, 0); final String routingAsString = routing.toString(); - IllegalShardRoutingStateException serialize = serialize(new IllegalShardRoutingStateException(routing, "foo", new NullPointerException())); + IllegalShardRoutingStateException serialize = serialize( + new IllegalShardRoutingStateException(routing, "foo", new NullPointerException())); assertNotNull(serialize.shard()); assertEquals(routing, serialize.shard()); assertEquals(routingAsString + ": foo", serialize.getMessage()); @@ -292,7 +303,8 @@ public class ExceptionSerializationTests extends ESTestCase { } public void testSnapshotException() throws IOException { - SnapshotException ex = serialize(new SnapshotException(new SnapshotId("repo", "snap"), "no such snapshot", new NullPointerException())); + SnapshotException ex = serialize( + new SnapshotException(new SnapshotId("repo", "snap"), "no such snapshot", new NullPointerException())); assertEquals(ex.snapshot(), new SnapshotId("repo", "snap")); assertEquals(ex.getMessage(), "[repo:snap] no such snapshot"); assertTrue(ex.getCause() instanceof NullPointerException); @@ -333,7 +345,8 @@ public class ExceptionSerializationTests extends ESTestCase { public void testBatchOperationException() throws IOException { ShardId id = new ShardId("foo", "_na_", 1); - TranslogRecoveryPerformer.BatchOperationException ex = serialize(new TranslogRecoveryPerformer.BatchOperationException(id, "batched the fucker", 666, null)); + TranslogRecoveryPerformer.BatchOperationException ex = serialize( + new TranslogRecoveryPerformer.BatchOperationException(id, "batched the fucker", 666, null)); assertEquals(ex.getShardId(), id); assertEquals(666, ex.completedOperations()); assertEquals("batched the fucker", ex.getMessage()); @@ -356,7 +369,8 @@ public class ExceptionSerializationTests extends ESTestCase { } public void testActionTransportException() throws IOException { - ActionTransportException ex = serialize(new ActionTransportException("name?", new LocalTransportAddress("dead.end:666"), "ACTION BABY!", "message?", null)); + ActionTransportException ex = serialize( + new ActionTransportException("name?", new LocalTransportAddress("dead.end:666"), "ACTION BABY!", "message?", null)); assertEquals("ACTION BABY!", ex.action()); assertEquals(new LocalTransportAddress("dead.end:666"), ex.address()); assertEquals("[name?][local[dead.end:666]][ACTION BABY!] message?", ex.getMessage());