From f4ff6647adaa28c46a35226d3d7ee3663bc2840a Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Fri, 25 Sep 2015 16:42:42 +0200 Subject: [PATCH 1/4] Remove reflection hacks from ElasticsearchException Today we use reflection where it's not needed anymore since java8 can pass ctors around. This commit replaces runtime checks with compile time checks which is always preferrable. --- .../elasticsearch/ElasticsearchException.java | 340 +++++++++--------- 1 file changed, 174 insertions(+), 166 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index c82cab9a35f..f6d8814a854 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -30,8 +30,6 @@ import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.rest.RestStatus; import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.*; /** @@ -48,8 +46,8 @@ public class ElasticsearchException extends RuntimeException implements ToXConte private static final String RESOURCE_HEADER_TYPE_KEY = "es.resource.type"; private static final String RESOURCE_HEADER_ID_KEY = "es.resource.id"; - private static final Constructor[] ID_TO_SUPPLIER; - private static final Map, Integer> CLASS_TO_ID; + private static final IOFunction[] ID_TO_SUPPLIER; + private static final Map, IdAndCtor> CLASS_TO_ID; private final Map> headers = new HashMap<>(); /** @@ -232,15 +230,11 @@ public class ElasticsearchException extends RuntimeException implements ToXConte } public static ElasticsearchException readException(StreamInput input, int id) throws IOException { - Constructor elasticsearchException = ID_TO_SUPPLIER[id]; + IOFunction elasticsearchException = ID_TO_SUPPLIER[id]; if (elasticsearchException == null) { throw new IllegalStateException("unknown exception for id: " + id); } - try { - return elasticsearchException.newInstance(input); - } catch (InstantiationException|IllegalAccessException|InvocationTargetException e) { - throw new IOException("failed to read exception for id [" + id + "]", e); - } + return elasticsearchException.apply(input); } /** @@ -258,7 +252,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte * Returns the serialization id the given exception. */ public static int getId(Class exception) { - return CLASS_TO_ID.get(exception).intValue(); + return CLASS_TO_ID.get(exception).id; } @Override @@ -464,164 +458,157 @@ public class ElasticsearchException extends RuntimeException implements ToXConte // to deserialize the exception coming from another node or from an corruption marker on // a corrupted index. // NOTE: ONLY APPEND TO THE END and NEVER REMOVE EXCEPTIONS IN MINOR VERSIONS - final Map, Integer> exceptions = new HashMap<>(); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, exceptions.size()); - exceptions.put(org.elasticsearch.discovery.MasterNotDiscoveredException.class, exceptions.size()); - exceptions.put(org.elasticsearch.ElasticsearchSecurityException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.IndexClosedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.http.BindHttpException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.search.ReduceSearchPhaseException.class, exceptions.size()); - exceptions.put(org.elasticsearch.node.NodeClosedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.ShardNotFoundException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.ConnectTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.NotSerializableTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.IndexCreationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.IndexNotFoundException.class, exceptions.size()); - exceptions.put(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.ResourceNotFoundException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.ActionTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.ElasticsearchGenerationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.CreateFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardStartedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.SearchContextMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.script.ScriptException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.snapshots.SnapshotCreationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.DeleteFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.DocumentMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.snapshots.SnapshotException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.InvalidAliasNameException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.InvalidIndexNameException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.TransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.ElasticsearchParseException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.SearchException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.mapper.MapperException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.InvalidTypeNameException.class, exceptions.size()); - exceptions.put(org.elasticsearch.snapshots.SnapshotRestoreException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.ParsingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardClosedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.translog.TruncatedTranslogException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.recovery.RecoveryFailedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardRelocatedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.NodeShouldNotConnectException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.translog.TranslogCorruptedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.cluster.block.ClusterBlockException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.IndexShardAlreadyExistsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.VersionConflictEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.EngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.DocumentAlreadyExistsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.NoSuchNodeException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.settings.SettingsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.IndexTemplateMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.SendRequestTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.cluster.routing.RoutingValidationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.AliasFilterParsingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.gateway.GatewayException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, exceptions.size()); - exceptions.put(org.elasticsearch.http.HttpException.class, exceptions.size()); - exceptions.put(org.elasticsearch.ElasticsearchException.class, exceptions.size()); - exceptions.put(org.elasticsearch.snapshots.SnapshotMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.PrimaryMissingActionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.FailedNodeException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.SearchParseException.class, exceptions.size()); - exceptions.put(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.blobstore.BlobStoreException.class, exceptions.size()); - exceptions.put(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.RecoveryEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.TimestampParsingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.RoutingMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.IndexFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.repositories.RepositoryException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.NodeDisconnectedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.AlreadyExpiredException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.aggregations.AggregationExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.mapper.MergeMappingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.InvalidIndexTemplateException.class, exceptions.size()); - exceptions.put(org.elasticsearch.percolator.PercolateException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.RefreshFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.aggregations.AggregationInitializationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.recovery.DelayRecoveryException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.warmer.IndexWarmerMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.client.transport.NoNodeAvailableException.class, exceptions.size()); - exceptions.put(org.elasticsearch.script.groovy.GroovyScriptCompilationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardNotStartedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.search.SearchPhaseExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.ActionNotFoundTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.TransportSerializationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.RemoteTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.EngineCreationFailureException.class, exceptions.size()); - exceptions.put(org.elasticsearch.cluster.routing.RoutingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardRecoveryException.class, exceptions.size()); - exceptions.put(org.elasticsearch.repositories.RepositoryMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.percolator.PercolatorException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.DocumentSourceMissingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.settings.NoClassSettingsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.BindTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.shard.IndexShardRecoveringException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.translog.TranslogException.class, exceptions.size()); - exceptions.put(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, exceptions.size()); - exceptions.put(org.elasticsearch.ElasticsearchTimeoutException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.query.QueryPhaseExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.repositories.RepositoryVerificationException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, exceptions.size()); - exceptions.put(org.elasticsearch.script.groovy.GroovyScriptExecutionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.IndexAlreadyExistsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.script.Script.ScriptParseException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.mapper.MapperParsingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.SearchContextException.class, exceptions.size()); - exceptions.put(org.elasticsearch.search.builder.SearchSourceBuilderException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.EngineClosedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.NoShardAvailableActionException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.UnavailableShardsException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.engine.FlushFailedEngineException.class, exceptions.size()); - exceptions.put(org.elasticsearch.common.breaker.CircuitBreakingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.transport.NodeNotConnectedException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, exceptions.size()); - exceptions.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, exceptions.size()); - exceptions.put(org.elasticsearch.indices.TypeMissingException.class, exceptions.size()); + final Map, IdAndCtor> exceptions = new HashMap<>(); + exceptions.put(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.search.dfs.DfsPhaseExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, new IdAndCtor(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, exceptions.size())); + exceptions.put(org.elasticsearch.discovery.MasterNotDiscoveredException.class, new IdAndCtor(org.elasticsearch.discovery.MasterNotDiscoveredException::new, exceptions.size())); + exceptions.put(org.elasticsearch.ElasticsearchSecurityException.class, new IdAndCtor(org.elasticsearch.ElasticsearchSecurityException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardRestoreException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.IndexClosedException.class, new IdAndCtor(org.elasticsearch.indices.IndexClosedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.http.BindHttpException.class, new IdAndCtor(org.elasticsearch.http.BindHttpException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.search.ReduceSearchPhaseException.class, new IdAndCtor(org.elasticsearch.action.search.ReduceSearchPhaseException::new, exceptions.size())); + exceptions.put(org.elasticsearch.node.NodeClosedException.class, new IdAndCtor(org.elasticsearch.node.NodeClosedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.SnapshotFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.ShardNotFoundException.class, new IdAndCtor(org.elasticsearch.index.shard.ShardNotFoundException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.ConnectTransportException.class, new IdAndCtor(org.elasticsearch.transport.ConnectTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.NotSerializableTransportException.class, new IdAndCtor(org.elasticsearch.transport.NotSerializableTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, new IdAndCtor(org.elasticsearch.transport.ResponseHandlerFailureTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.IndexCreationException.class, new IdAndCtor(org.elasticsearch.indices.IndexCreationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.IndexNotFoundException.class, new IdAndCtor(org.elasticsearch.index.IndexNotFoundException::new, exceptions.size())); + exceptions.put(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, new IdAndCtor(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, new IdAndCtor(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.ResourceNotFoundException.class, new IdAndCtor(org.elasticsearch.ResourceNotFoundException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.ActionTransportException.class, new IdAndCtor(org.elasticsearch.transport.ActionTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.ElasticsearchGenerationException.class, new IdAndCtor(org.elasticsearch.ElasticsearchGenerationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.CreateFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.CreateFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardStartedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardStartedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.SearchContextMissingException.class, new IdAndCtor(org.elasticsearch.search.SearchContextMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.script.ScriptException.class, new IdAndCtor(org.elasticsearch.script.ScriptException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, new IdAndCtor(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.snapshots.SnapshotCreationException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotCreationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.DeleteFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.DeleteFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.DocumentMissingException.class, new IdAndCtor(org.elasticsearch.index.engine.DocumentMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.snapshots.SnapshotException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.InvalidAliasNameException.class, new IdAndCtor(org.elasticsearch.indices.InvalidAliasNameException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.InvalidIndexNameException.class, new IdAndCtor(org.elasticsearch.indices.InvalidIndexNameException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, new IdAndCtor(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.TransportException.class, new IdAndCtor(org.elasticsearch.transport.TransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.ElasticsearchParseException.class, new IdAndCtor(org.elasticsearch.ElasticsearchParseException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.SearchException.class, new IdAndCtor(org.elasticsearch.search.SearchException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.mapper.MapperException.class, new IdAndCtor(org.elasticsearch.index.mapper.MapperException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.InvalidTypeNameException.class, new IdAndCtor(org.elasticsearch.indices.InvalidTypeNameException::new, exceptions.size())); + exceptions.put(org.elasticsearch.snapshots.SnapshotRestoreException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotRestoreException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.ParsingException.class, new IdAndCtor(org.elasticsearch.common.ParsingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardClosedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardClosedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, new IdAndCtor(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.translog.TruncatedTranslogException.class, new IdAndCtor(org.elasticsearch.index.translog.TruncatedTranslogException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.recovery.RecoveryFailedException.class, new IdAndCtor(org.elasticsearch.indices.recovery.RecoveryFailedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardRelocatedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardRelocatedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.NodeShouldNotConnectException.class, new IdAndCtor(org.elasticsearch.transport.NodeShouldNotConnectException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.indices.IndexTemplateAlreadyExistsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.translog.TranslogCorruptedException.class, new IdAndCtor(org.elasticsearch.index.translog.TranslogCorruptedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.cluster.block.ClusterBlockException.class, new IdAndCtor(org.elasticsearch.cluster.block.ClusterBlockException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.search.fetch.FetchPhaseExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.IndexShardAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.index.IndexShardAlreadyExistsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.VersionConflictEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.VersionConflictEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.EngineException.class, new IdAndCtor(org.elasticsearch.index.engine.EngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.DocumentAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.index.engine.DocumentAlreadyExistsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.NoSuchNodeException.class, new IdAndCtor(org.elasticsearch.action.NoSuchNodeException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.settings.SettingsException.class, new IdAndCtor(org.elasticsearch.common.settings.SettingsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.IndexTemplateMissingException.class, new IdAndCtor(org.elasticsearch.indices.IndexTemplateMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.SendRequestTransportException.class, new IdAndCtor(org.elasticsearch.transport.SendRequestTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, new IdAndCtor(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, new IdAndCtor(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.cluster.routing.RoutingValidationException.class, new IdAndCtor(org.elasticsearch.cluster.routing.RoutingValidationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, new IdAndCtor(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.AliasFilterParsingException.class, new IdAndCtor(org.elasticsearch.indices.AliasFilterParsingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.gateway.GatewayException.class, new IdAndCtor(org.elasticsearch.gateway.GatewayException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardNotRecoveringException::new, exceptions.size())); + exceptions.put(org.elasticsearch.http.HttpException.class, new IdAndCtor(org.elasticsearch.http.HttpException::new, exceptions.size())); + exceptions.put(org.elasticsearch.ElasticsearchException.class, new IdAndCtor(org.elasticsearch.ElasticsearchException::new, exceptions.size())); + exceptions.put(org.elasticsearch.snapshots.SnapshotMissingException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.PrimaryMissingActionException.class, new IdAndCtor(org.elasticsearch.action.PrimaryMissingActionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.FailedNodeException.class, new IdAndCtor(org.elasticsearch.action.FailedNodeException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.SearchParseException.class, new IdAndCtor(org.elasticsearch.search.SearchParseException::new, exceptions.size())); + exceptions.put(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, new IdAndCtor(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.blobstore.BlobStoreException.class, new IdAndCtor(org.elasticsearch.common.blobstore.BlobStoreException::new, exceptions.size())); + exceptions.put(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, new IdAndCtor(org.elasticsearch.cluster.IncompatibleClusterStateVersionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.RecoveryEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.RecoveryEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, new IdAndCtor(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.TimestampParsingException.class, new IdAndCtor(org.elasticsearch.action.TimestampParsingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.RoutingMissingException.class, new IdAndCtor(org.elasticsearch.action.RoutingMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.IndexFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.IndexFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.repositories.RepositoryException.class, new IdAndCtor(org.elasticsearch.repositories.RepositoryException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, new IdAndCtor(org.elasticsearch.transport.ReceiveTimeoutTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.NodeDisconnectedException.class, new IdAndCtor(org.elasticsearch.transport.NodeDisconnectedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.AlreadyExpiredException.class, new IdAndCtor(org.elasticsearch.index.AlreadyExpiredException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.aggregations.AggregationExecutionException.class, new IdAndCtor(org.elasticsearch.search.aggregations.AggregationExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.mapper.MergeMappingException.class, new IdAndCtor(org.elasticsearch.index.mapper.MergeMappingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.InvalidIndexTemplateException.class, new IdAndCtor(org.elasticsearch.indices.InvalidIndexTemplateException::new, exceptions.size())); + exceptions.put(org.elasticsearch.percolator.PercolateException.class, new IdAndCtor(org.elasticsearch.percolator.PercolateException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.RefreshFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.RefreshFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.aggregations.AggregationInitializationException.class, new IdAndCtor(org.elasticsearch.search.aggregations.AggregationInitializationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.recovery.DelayRecoveryException.class, new IdAndCtor(org.elasticsearch.indices.recovery.DelayRecoveryException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.warmer.IndexWarmerMissingException.class, new IdAndCtor(org.elasticsearch.search.warmer.IndexWarmerMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.client.transport.NoNodeAvailableException.class, new IdAndCtor(org.elasticsearch.client.transport.NoNodeAvailableException::new, exceptions.size())); + exceptions.put(org.elasticsearch.script.groovy.GroovyScriptCompilationException.class, new IdAndCtor(org.elasticsearch.script.groovy.GroovyScriptCompilationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, new IdAndCtor(org.elasticsearch.snapshots.InvalidSnapshotNameException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, new IdAndCtor(org.elasticsearch.index.shard.IllegalIndexShardStateException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardSnapshotException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardNotStartedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardNotStartedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.search.SearchPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.action.search.SearchPhaseExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.ActionNotFoundTransportException.class, new IdAndCtor(org.elasticsearch.transport.ActionNotFoundTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.TransportSerializationException.class, new IdAndCtor(org.elasticsearch.transport.TransportSerializationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.RemoteTransportException.class, new IdAndCtor(org.elasticsearch.transport.RemoteTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.EngineCreationFailureException.class, new IdAndCtor(org.elasticsearch.index.engine.EngineCreationFailureException::new, exceptions.size())); + exceptions.put(org.elasticsearch.cluster.routing.RoutingException.class, new IdAndCtor(org.elasticsearch.cluster.routing.RoutingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardRecoveryException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardRecoveryException::new, exceptions.size())); + exceptions.put(org.elasticsearch.repositories.RepositoryMissingException.class, new IdAndCtor(org.elasticsearch.repositories.RepositoryMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.percolator.PercolatorException.class, new IdAndCtor(org.elasticsearch.index.percolator.PercolatorException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.DocumentSourceMissingException.class, new IdAndCtor(org.elasticsearch.index.engine.DocumentSourceMissingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.FlushNotAllowedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.settings.NoClassSettingsException.class, new IdAndCtor(org.elasticsearch.common.settings.NoClassSettingsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.BindTransportException.class, new IdAndCtor(org.elasticsearch.transport.BindTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, new IdAndCtor(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.shard.IndexShardRecoveringException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardRecoveringException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.translog.TranslogException.class, new IdAndCtor(org.elasticsearch.index.translog.TranslogException::new, exceptions.size())); + exceptions.put(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, new IdAndCtor(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, new IdAndCtor(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException::new, exceptions.size())); + exceptions.put(org.elasticsearch.ElasticsearchTimeoutException.class, new IdAndCtor(org.elasticsearch.ElasticsearchTimeoutException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.query.QueryPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.search.query.QueryPhaseExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.repositories.RepositoryVerificationException.class, new IdAndCtor(org.elasticsearch.repositories.RepositoryVerificationException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, new IdAndCtor(org.elasticsearch.search.aggregations.InvalidAggregationPathException::new, exceptions.size())); + exceptions.put(org.elasticsearch.script.groovy.GroovyScriptExecutionException.class, new IdAndCtor(org.elasticsearch.script.groovy.GroovyScriptExecutionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.IndexAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.indices.IndexAlreadyExistsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.script.Script.ScriptParseException.class, new IdAndCtor(org.elasticsearch.script.Script.ScriptParseException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, new IdAndCtor(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.mapper.MapperParsingException.class, new IdAndCtor(org.elasticsearch.index.mapper.MapperParsingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.SearchContextException.class, new IdAndCtor(org.elasticsearch.search.SearchContextException::new, exceptions.size())); + exceptions.put(org.elasticsearch.search.builder.SearchSourceBuilderException.class, new IdAndCtor(org.elasticsearch.search.builder.SearchSourceBuilderException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.EngineClosedException.class, new IdAndCtor(org.elasticsearch.index.engine.EngineClosedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.NoShardAvailableActionException.class, new IdAndCtor(org.elasticsearch.action.NoShardAvailableActionException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.UnavailableShardsException.class, new IdAndCtor(org.elasticsearch.action.UnavailableShardsException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.engine.FlushFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.FlushFailedEngineException::new, exceptions.size())); + exceptions.put(org.elasticsearch.common.breaker.CircuitBreakingException.class, new IdAndCtor(org.elasticsearch.common.breaker.CircuitBreakingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.transport.NodeNotConnectedException.class, new IdAndCtor(org.elasticsearch.transport.NodeNotConnectedException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, new IdAndCtor(org.elasticsearch.index.mapper.StrictDynamicMappingException::new, exceptions.size())); + exceptions.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, new IdAndCtor(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException::new, exceptions.size())); + exceptions.put(org.elasticsearch.indices.TypeMissingException.class, new IdAndCtor(org.elasticsearch.indices.TypeMissingException::new, exceptions.size())); // added in 3.x - exceptions.put(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, exceptions.size()); - exceptions.put(org.elasticsearch.index.query.QueryShardException.class, exceptions.size()); + exceptions.put(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, new IdAndCtor(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException::new, exceptions.size())); + exceptions.put(org.elasticsearch.index.query.QueryShardException.class, new IdAndCtor(org.elasticsearch.index.query.QueryShardException::new, exceptions.size())); // NOTE: ONLY APPEND TO THE END and NEVER REMOVE EXCEPTIONS IN MINOR VERSIONS - Constructor[] idToSupplier = new Constructor[exceptions.size()]; - for (Map.Entry, Integer> e : exceptions.entrySet()) { - try { - Constructor constructor = e.getKey().getDeclaredConstructor(StreamInput.class); - if (constructor == null) { - throw new IllegalStateException(e.getKey().getName() + " has not StreamInput ctor"); - } - assert e.getValue().intValue() >= 0; - if (idToSupplier[e.getValue().intValue()] != null) { - throw new IllegalStateException("ordinal [" + e.getValue().intValue() +"] is used more than once"); - } - idToSupplier[e.getValue().intValue()] = constructor; - } catch (NoSuchMethodException t) { - throw new RuntimeException("failed to register [" + e.getKey().getName() + "] exception must have a public StreamInput ctor", t); + IOFunction[] idToSupplier = new IOFunction[exceptions.size()]; + for (Map.Entry, IdAndCtor> e : exceptions.entrySet()) { + IdAndCtor value = e.getValue(); + assert value.id >= 0; + if (idToSupplier[value.id] != null) { + throw new IllegalStateException("ordinal [" + value.id +"] is used more than once"); } + idToSupplier[value.id] = value.ctor; } for (int i = 0; i < idToSupplier.length; i++) { if (idToSupplier[i] == null) { @@ -702,4 +689,25 @@ public class ElasticsearchException extends RuntimeException implements ToXConte ElasticsearchException.toXContent(builder, params, t); builder.endObject(); } + + interface IOFunction { + + /** + * Applies this function to the given argument. + * + * @param t the function argument + * @return the function result + */ + R apply(T t) throws IOException; + } + + static class IdAndCtor { + final IOFunction ctor; + final int id; + + IdAndCtor(IOFunction ctor, int id) { + this.ctor = ctor; + this.id = id; + } + } } From 752b4798d1f08e9f27aab847e0250eff86eb6c2c Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 25 Sep 2015 14:32:44 -0400 Subject: [PATCH 2/4] Use explicit ids for ElasticsearchExceptions This commit adds explicit ids for managing ElasticsearchException serialization. By adding explicit ids and unit tests for them, the ids are less brittle and breakage can be more clearly detected. --- .../elasticsearch/ElasticsearchException.java | 348 +++++++++--------- .../ExceptionSerializationTests.java | 169 +++++++++ 2 files changed, 335 insertions(+), 182 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index f6d8814a854..7422ab7834d 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -31,6 +31,7 @@ import org.elasticsearch.rest.RestStatus; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; /** * A base class for all elasticsearch exceptions. @@ -46,8 +47,8 @@ public class ElasticsearchException extends RuntimeException implements ToXConte private static final String RESOURCE_HEADER_TYPE_KEY = "es.resource.type"; private static final String RESOURCE_HEADER_ID_KEY = "es.resource.id"; - private static final IOFunction[] ID_TO_SUPPLIER; - private static final Map, IdAndCtor> CLASS_TO_ID; + private static final FunctionThatThrowsIOException[] ID_TO_SUPPLIER; + private static final Map, ElasticsearchExceptionHandle> CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE; private final Map> headers = new HashMap<>(); /** @@ -230,7 +231,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte } public static ElasticsearchException readException(StreamInput input, int id) throws IOException { - IOFunction elasticsearchException = ID_TO_SUPPLIER[id]; + FunctionThatThrowsIOException elasticsearchException = ID_TO_SUPPLIER[id]; if (elasticsearchException == null) { throw new IllegalStateException("unknown exception for id: " + id); } @@ -241,18 +242,18 @@ public class ElasticsearchException extends RuntimeException implements ToXConte * Retruns true iff the given class is a registered for an exception to be read. */ public static boolean isRegistered(Class exception) { - return CLASS_TO_ID.containsKey(exception); + return CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE.containsKey(exception); } static Set> getRegisteredKeys() { // for testing - return CLASS_TO_ID.keySet(); + return CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE.keySet(); } /** * Returns the serialization id the given exception. */ public static int getId(Class exception) { - return CLASS_TO_ID.get(exception).id; + return CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE.get(exception).id; } @Override @@ -452,172 +453,172 @@ public class ElasticsearchException extends RuntimeException implements ToXConte return throwable; } - static { + enum ElasticsearchExceptionHandle { // each exception gets an ordinal assigned 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. // NOTE: ONLY APPEND TO THE END and NEVER REMOVE EXCEPTIONS IN MINOR VERSIONS - final Map, IdAndCtor> exceptions = new HashMap<>(); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.search.dfs.DfsPhaseExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, new IdAndCtor(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, exceptions.size())); - exceptions.put(org.elasticsearch.discovery.MasterNotDiscoveredException.class, new IdAndCtor(org.elasticsearch.discovery.MasterNotDiscoveredException::new, exceptions.size())); - exceptions.put(org.elasticsearch.ElasticsearchSecurityException.class, new IdAndCtor(org.elasticsearch.ElasticsearchSecurityException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardRestoreException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.IndexClosedException.class, new IdAndCtor(org.elasticsearch.indices.IndexClosedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.http.BindHttpException.class, new IdAndCtor(org.elasticsearch.http.BindHttpException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.search.ReduceSearchPhaseException.class, new IdAndCtor(org.elasticsearch.action.search.ReduceSearchPhaseException::new, exceptions.size())); - exceptions.put(org.elasticsearch.node.NodeClosedException.class, new IdAndCtor(org.elasticsearch.node.NodeClosedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.SnapshotFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.ShardNotFoundException.class, new IdAndCtor(org.elasticsearch.index.shard.ShardNotFoundException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.ConnectTransportException.class, new IdAndCtor(org.elasticsearch.transport.ConnectTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.NotSerializableTransportException.class, new IdAndCtor(org.elasticsearch.transport.NotSerializableTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, new IdAndCtor(org.elasticsearch.transport.ResponseHandlerFailureTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.IndexCreationException.class, new IdAndCtor(org.elasticsearch.indices.IndexCreationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.IndexNotFoundException.class, new IdAndCtor(org.elasticsearch.index.IndexNotFoundException::new, exceptions.size())); - exceptions.put(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, new IdAndCtor(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, new IdAndCtor(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.ResourceNotFoundException.class, new IdAndCtor(org.elasticsearch.ResourceNotFoundException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.ActionTransportException.class, new IdAndCtor(org.elasticsearch.transport.ActionTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.ElasticsearchGenerationException.class, new IdAndCtor(org.elasticsearch.ElasticsearchGenerationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.CreateFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.CreateFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardStartedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardStartedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.SearchContextMissingException.class, new IdAndCtor(org.elasticsearch.search.SearchContextMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.script.ScriptException.class, new IdAndCtor(org.elasticsearch.script.ScriptException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, new IdAndCtor(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.snapshots.SnapshotCreationException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotCreationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.DeleteFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.DeleteFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.DocumentMissingException.class, new IdAndCtor(org.elasticsearch.index.engine.DocumentMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.snapshots.SnapshotException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.InvalidAliasNameException.class, new IdAndCtor(org.elasticsearch.indices.InvalidAliasNameException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.InvalidIndexNameException.class, new IdAndCtor(org.elasticsearch.indices.InvalidIndexNameException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, new IdAndCtor(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.TransportException.class, new IdAndCtor(org.elasticsearch.transport.TransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.ElasticsearchParseException.class, new IdAndCtor(org.elasticsearch.ElasticsearchParseException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.SearchException.class, new IdAndCtor(org.elasticsearch.search.SearchException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.mapper.MapperException.class, new IdAndCtor(org.elasticsearch.index.mapper.MapperException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.InvalidTypeNameException.class, new IdAndCtor(org.elasticsearch.indices.InvalidTypeNameException::new, exceptions.size())); - exceptions.put(org.elasticsearch.snapshots.SnapshotRestoreException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotRestoreException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.ParsingException.class, new IdAndCtor(org.elasticsearch.common.ParsingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardClosedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardClosedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, new IdAndCtor(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.translog.TruncatedTranslogException.class, new IdAndCtor(org.elasticsearch.index.translog.TruncatedTranslogException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.recovery.RecoveryFailedException.class, new IdAndCtor(org.elasticsearch.indices.recovery.RecoveryFailedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardRelocatedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardRelocatedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.NodeShouldNotConnectException.class, new IdAndCtor(org.elasticsearch.transport.NodeShouldNotConnectException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.indices.IndexTemplateAlreadyExistsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.translog.TranslogCorruptedException.class, new IdAndCtor(org.elasticsearch.index.translog.TranslogCorruptedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.cluster.block.ClusterBlockException.class, new IdAndCtor(org.elasticsearch.cluster.block.ClusterBlockException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.search.fetch.FetchPhaseExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.IndexShardAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.index.IndexShardAlreadyExistsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.VersionConflictEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.VersionConflictEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.EngineException.class, new IdAndCtor(org.elasticsearch.index.engine.EngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.DocumentAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.index.engine.DocumentAlreadyExistsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.NoSuchNodeException.class, new IdAndCtor(org.elasticsearch.action.NoSuchNodeException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.settings.SettingsException.class, new IdAndCtor(org.elasticsearch.common.settings.SettingsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.IndexTemplateMissingException.class, new IdAndCtor(org.elasticsearch.indices.IndexTemplateMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.SendRequestTransportException.class, new IdAndCtor(org.elasticsearch.transport.SendRequestTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, new IdAndCtor(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, new IdAndCtor(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.cluster.routing.RoutingValidationException.class, new IdAndCtor(org.elasticsearch.cluster.routing.RoutingValidationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, new IdAndCtor(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.AliasFilterParsingException.class, new IdAndCtor(org.elasticsearch.indices.AliasFilterParsingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.gateway.GatewayException.class, new IdAndCtor(org.elasticsearch.gateway.GatewayException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardNotRecoveringException::new, exceptions.size())); - exceptions.put(org.elasticsearch.http.HttpException.class, new IdAndCtor(org.elasticsearch.http.HttpException::new, exceptions.size())); - exceptions.put(org.elasticsearch.ElasticsearchException.class, new IdAndCtor(org.elasticsearch.ElasticsearchException::new, exceptions.size())); - exceptions.put(org.elasticsearch.snapshots.SnapshotMissingException.class, new IdAndCtor(org.elasticsearch.snapshots.SnapshotMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.PrimaryMissingActionException.class, new IdAndCtor(org.elasticsearch.action.PrimaryMissingActionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.FailedNodeException.class, new IdAndCtor(org.elasticsearch.action.FailedNodeException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.SearchParseException.class, new IdAndCtor(org.elasticsearch.search.SearchParseException::new, exceptions.size())); - exceptions.put(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, new IdAndCtor(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.blobstore.BlobStoreException.class, new IdAndCtor(org.elasticsearch.common.blobstore.BlobStoreException::new, exceptions.size())); - exceptions.put(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, new IdAndCtor(org.elasticsearch.cluster.IncompatibleClusterStateVersionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.RecoveryEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.RecoveryEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, new IdAndCtor(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.TimestampParsingException.class, new IdAndCtor(org.elasticsearch.action.TimestampParsingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.RoutingMissingException.class, new IdAndCtor(org.elasticsearch.action.RoutingMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.IndexFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.IndexFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.repositories.RepositoryException.class, new IdAndCtor(org.elasticsearch.repositories.RepositoryException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, new IdAndCtor(org.elasticsearch.transport.ReceiveTimeoutTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.NodeDisconnectedException.class, new IdAndCtor(org.elasticsearch.transport.NodeDisconnectedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.AlreadyExpiredException.class, new IdAndCtor(org.elasticsearch.index.AlreadyExpiredException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.aggregations.AggregationExecutionException.class, new IdAndCtor(org.elasticsearch.search.aggregations.AggregationExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.mapper.MergeMappingException.class, new IdAndCtor(org.elasticsearch.index.mapper.MergeMappingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.InvalidIndexTemplateException.class, new IdAndCtor(org.elasticsearch.indices.InvalidIndexTemplateException::new, exceptions.size())); - exceptions.put(org.elasticsearch.percolator.PercolateException.class, new IdAndCtor(org.elasticsearch.percolator.PercolateException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.RefreshFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.RefreshFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.aggregations.AggregationInitializationException.class, new IdAndCtor(org.elasticsearch.search.aggregations.AggregationInitializationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.recovery.DelayRecoveryException.class, new IdAndCtor(org.elasticsearch.indices.recovery.DelayRecoveryException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.warmer.IndexWarmerMissingException.class, new IdAndCtor(org.elasticsearch.search.warmer.IndexWarmerMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.client.transport.NoNodeAvailableException.class, new IdAndCtor(org.elasticsearch.client.transport.NoNodeAvailableException::new, exceptions.size())); - exceptions.put(org.elasticsearch.script.groovy.GroovyScriptCompilationException.class, new IdAndCtor(org.elasticsearch.script.groovy.GroovyScriptCompilationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, new IdAndCtor(org.elasticsearch.snapshots.InvalidSnapshotNameException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, new IdAndCtor(org.elasticsearch.index.shard.IllegalIndexShardStateException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, new IdAndCtor(org.elasticsearch.index.snapshots.IndexShardSnapshotException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardNotStartedException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardNotStartedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.search.SearchPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.action.search.SearchPhaseExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.ActionNotFoundTransportException.class, new IdAndCtor(org.elasticsearch.transport.ActionNotFoundTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.TransportSerializationException.class, new IdAndCtor(org.elasticsearch.transport.TransportSerializationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.RemoteTransportException.class, new IdAndCtor(org.elasticsearch.transport.RemoteTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.EngineCreationFailureException.class, new IdAndCtor(org.elasticsearch.index.engine.EngineCreationFailureException::new, exceptions.size())); - exceptions.put(org.elasticsearch.cluster.routing.RoutingException.class, new IdAndCtor(org.elasticsearch.cluster.routing.RoutingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardRecoveryException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardRecoveryException::new, exceptions.size())); - exceptions.put(org.elasticsearch.repositories.RepositoryMissingException.class, new IdAndCtor(org.elasticsearch.repositories.RepositoryMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.percolator.PercolatorException.class, new IdAndCtor(org.elasticsearch.index.percolator.PercolatorException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.DocumentSourceMissingException.class, new IdAndCtor(org.elasticsearch.index.engine.DocumentSourceMissingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.FlushNotAllowedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.settings.NoClassSettingsException.class, new IdAndCtor(org.elasticsearch.common.settings.NoClassSettingsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.BindTransportException.class, new IdAndCtor(org.elasticsearch.transport.BindTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, new IdAndCtor(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.shard.IndexShardRecoveringException.class, new IdAndCtor(org.elasticsearch.index.shard.IndexShardRecoveringException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.translog.TranslogException.class, new IdAndCtor(org.elasticsearch.index.translog.TranslogException::new, exceptions.size())); - exceptions.put(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, new IdAndCtor(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, new IdAndCtor(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException::new, exceptions.size())); - exceptions.put(org.elasticsearch.ElasticsearchTimeoutException.class, new IdAndCtor(org.elasticsearch.ElasticsearchTimeoutException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.query.QueryPhaseExecutionException.class, new IdAndCtor(org.elasticsearch.search.query.QueryPhaseExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.repositories.RepositoryVerificationException.class, new IdAndCtor(org.elasticsearch.repositories.RepositoryVerificationException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, new IdAndCtor(org.elasticsearch.search.aggregations.InvalidAggregationPathException::new, exceptions.size())); - exceptions.put(org.elasticsearch.script.groovy.GroovyScriptExecutionException.class, new IdAndCtor(org.elasticsearch.script.groovy.GroovyScriptExecutionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.IndexAlreadyExistsException.class, new IdAndCtor(org.elasticsearch.indices.IndexAlreadyExistsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.script.Script.ScriptParseException.class, new IdAndCtor(org.elasticsearch.script.Script.ScriptParseException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, new IdAndCtor(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.mapper.MapperParsingException.class, new IdAndCtor(org.elasticsearch.index.mapper.MapperParsingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.SearchContextException.class, new IdAndCtor(org.elasticsearch.search.SearchContextException::new, exceptions.size())); - exceptions.put(org.elasticsearch.search.builder.SearchSourceBuilderException.class, new IdAndCtor(org.elasticsearch.search.builder.SearchSourceBuilderException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.EngineClosedException.class, new IdAndCtor(org.elasticsearch.index.engine.EngineClosedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.NoShardAvailableActionException.class, new IdAndCtor(org.elasticsearch.action.NoShardAvailableActionException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.UnavailableShardsException.class, new IdAndCtor(org.elasticsearch.action.UnavailableShardsException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.engine.FlushFailedEngineException.class, new IdAndCtor(org.elasticsearch.index.engine.FlushFailedEngineException::new, exceptions.size())); - exceptions.put(org.elasticsearch.common.breaker.CircuitBreakingException.class, new IdAndCtor(org.elasticsearch.common.breaker.CircuitBreakingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.transport.NodeNotConnectedException.class, new IdAndCtor(org.elasticsearch.transport.NodeNotConnectedException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, new IdAndCtor(org.elasticsearch.index.mapper.StrictDynamicMappingException::new, exceptions.size())); - exceptions.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, new IdAndCtor(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException::new, exceptions.size())); - exceptions.put(org.elasticsearch.indices.TypeMissingException.class, new IdAndCtor(org.elasticsearch.indices.TypeMissingException::new, exceptions.size())); - // added in 3.x - exceptions.put(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, new IdAndCtor(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException::new, exceptions.size())); - exceptions.put(org.elasticsearch.index.query.QueryShardException.class, new IdAndCtor(org.elasticsearch.index.query.QueryShardException::new, exceptions.size())); - // NOTE: ONLY APPEND TO THE END and NEVER REMOVE EXCEPTIONS IN MINOR VERSIONS - IOFunction[] idToSupplier = new IOFunction[exceptions.size()]; - for (Map.Entry, IdAndCtor> e : exceptions.entrySet()) { - IdAndCtor value = e.getValue(); - assert value.id >= 0; - if (idToSupplier[value.id] != null) { - throw new IllegalStateException("ordinal [" + value.id +"] is used more than once"); - } - idToSupplier[value.id] = value.ctor; - } - for (int i = 0; i < idToSupplier.length; i++) { - if (idToSupplier[i] == null) { - throw new IllegalStateException("missing exception for ordinal [" + i + "]"); - } + 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), + CREATE_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.CreateFailedEngineException.class, org.elasticsearch.index.engine.CreateFailedEngineException::new, 22), + 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), + 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), + ENGINE_EXCEPTION(org.elasticsearch.index.engine.EngineException.class, org.elasticsearch.index.engine.EngineException::new, 53), + DOCUMENT_ALREADY_EXISTS_EXCEPTION(org.elasticsearch.index.engine.DocumentAlreadyExistsException.class, org.elasticsearch.index.engine.DocumentAlreadyExistsException::new, 54), + 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), + DELETE_BY_QUERY_FAILED_ENGINE_EXCEPTION(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class, org.elasticsearch.index.engine.DeleteByQueryFailedEngineException::new, 64), + 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), + 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), + 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), + MERGE_MAPPING_EXCEPTION(org.elasticsearch.index.mapper.MergeMappingException.class, org.elasticsearch.index.mapper.MergeMappingException::new, 87), + 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), + INDEX_WARMER_MISSING_EXCEPTION(org.elasticsearch.search.warmer.IndexWarmerMissingException.class, org.elasticsearch.search.warmer.IndexWarmerMissingException::new, 93), + NO_NODE_AVAILABLE_EXCEPTION(org.elasticsearch.client.transport.NoNodeAvailableException.class, org.elasticsearch.client.transport.NoNodeAvailableException::new, 94), + GROOVY_SCRIPT_COMPILATION_EXCEPTION(org.elasticsearch.script.groovy.GroovyScriptCompilationException.class, org.elasticsearch.script.groovy.GroovyScriptCompilationException::new, 95), + 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), + GROOVY_SCRIPT_EXECUTION_EXCEPTION(org.elasticsearch.script.groovy.GroovyScriptExecutionException.class, org.elasticsearch.script.groovy.GroovyScriptExecutionException::new, 122), + 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, 138), + QUERY_SHARD_EXCEPTION(org.elasticsearch.index.query.QueryShardException.class, org.elasticsearch.index.query.QueryShardException::new, 139); + + final Class exceptionClass; + final FunctionThatThrowsIOException constructor; + final int id; + + ElasticsearchExceptionHandle(Class exceptionClass, FunctionThatThrowsIOException constructor, int id) { + this.exceptionClass = exceptionClass; + this.constructor = constructor; + this.id = id; } + } + + static { + final Map, ElasticsearchExceptionHandle> exceptions = Arrays.stream(ElasticsearchExceptionHandle.values()).collect(Collectors.toMap(e -> e.exceptionClass, e -> e)); + + FunctionThatThrowsIOException[] idToSupplier = new FunctionThatThrowsIOException[exceptions.size()]; + exceptions.entrySet().forEach(e -> idToSupplier[e.getValue().id] = e.getValue().constructor); ID_TO_SUPPLIER = idToSupplier; - CLASS_TO_ID = Collections.unmodifiableMap(exceptions); + CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE = Collections.unmodifiableMap(exceptions); } public String getIndex() { @@ -690,24 +691,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte builder.endObject(); } - interface IOFunction { - - /** - * Applies this function to the given argument. - * - * @param t the function argument - * @return the function result - */ + interface FunctionThatThrowsIOException { R apply(T t) throws IOException; } - - static class IdAndCtor { - final IOFunction ctor; - final int id; - - IdAndCtor(IOFunction ctor, int id) { - this.ctor = ctor; - this.id = id; - } - } } diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 6af4aa0e50f..b0e8c19ebf1 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -91,9 +91,13 @@ import java.nio.file.FileVisitor; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; + public class ExceptionSerializationTests extends ESTestCase { public void testExceptionRegistration() @@ -637,4 +641,169 @@ public class ExceptionSerializationTests extends ESTestCase { InterruptedException ex = serialize(orig); assertEquals(orig.getMessage(), ex.getMessage()); } + + public void testThatIdsArePositive() { + for (ElasticsearchException.ElasticsearchExceptionHandle handle : ElasticsearchException.ElasticsearchExceptionHandle.values()) { + assertThat("negative id", handle.id, greaterThanOrEqualTo(0)); + } + } + + public void testThatIdsAreUnique() { + Set ids = new HashSet<>(); + for (ElasticsearchException.ElasticsearchExceptionHandle handle : ElasticsearchException.ElasticsearchExceptionHandle.values()) { + assertTrue("duplicate id", ids.add(handle.id)); + } + } + + public void testIds() { + Map, Integer> ids = new HashMap<>(); + ids.put(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, 0); + ids.put(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, 1); + ids.put(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, 2); + ids.put(org.elasticsearch.discovery.MasterNotDiscoveredException.class, 3); + ids.put(org.elasticsearch.ElasticsearchSecurityException.class, 4); + ids.put(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, 5); + ids.put(org.elasticsearch.indices.IndexClosedException.class, 6); + ids.put(org.elasticsearch.http.BindHttpException.class, 7); + ids.put(org.elasticsearch.action.search.ReduceSearchPhaseException.class, 8); + ids.put(org.elasticsearch.node.NodeClosedException.class, 9); + ids.put(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, 10); + ids.put(org.elasticsearch.index.shard.ShardNotFoundException.class, 11); + ids.put(org.elasticsearch.transport.ConnectTransportException.class, 12); + ids.put(org.elasticsearch.transport.NotSerializableTransportException.class, 13); + ids.put(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, 14); + ids.put(org.elasticsearch.indices.IndexCreationException.class, 15); + ids.put(org.elasticsearch.index.IndexNotFoundException.class, 16); + ids.put(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, 17); + ids.put(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, 18); + ids.put(org.elasticsearch.ResourceNotFoundException.class, 19); + ids.put(org.elasticsearch.transport.ActionTransportException.class, 20); + ids.put(org.elasticsearch.ElasticsearchGenerationException.class, 21); + ids.put(org.elasticsearch.index.engine.CreateFailedEngineException.class, 22); + ids.put(org.elasticsearch.index.shard.IndexShardStartedException.class, 23); + ids.put(org.elasticsearch.search.SearchContextMissingException.class, 24); + ids.put(org.elasticsearch.script.ScriptException.class, 25); + ids.put(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, 26); + ids.put(org.elasticsearch.snapshots.SnapshotCreationException.class, 27); + ids.put(org.elasticsearch.index.engine.DeleteFailedEngineException.class, 28); + ids.put(org.elasticsearch.index.engine.DocumentMissingException.class, 29); + ids.put(org.elasticsearch.snapshots.SnapshotException.class, 30); + ids.put(org.elasticsearch.indices.InvalidAliasNameException.class, 31); + ids.put(org.elasticsearch.indices.InvalidIndexNameException.class, 32); + ids.put(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, 33); + ids.put(org.elasticsearch.transport.TransportException.class, 34); + ids.put(org.elasticsearch.ElasticsearchParseException.class, 35); + ids.put(org.elasticsearch.search.SearchException.class, 36); + ids.put(org.elasticsearch.index.mapper.MapperException.class, 37); + ids.put(org.elasticsearch.indices.InvalidTypeNameException.class, 38); + ids.put(org.elasticsearch.snapshots.SnapshotRestoreException.class, 39); + ids.put(org.elasticsearch.common.ParsingException.class, 40); + ids.put(org.elasticsearch.index.shard.IndexShardClosedException.class, 41); + ids.put(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, 42); + ids.put(org.elasticsearch.index.translog.TruncatedTranslogException.class, 43); + ids.put(org.elasticsearch.indices.recovery.RecoveryFailedException.class, 44); + ids.put(org.elasticsearch.index.shard.IndexShardRelocatedException.class, 45); + ids.put(org.elasticsearch.transport.NodeShouldNotConnectException.class, 46); + ids.put(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, 47); + ids.put(org.elasticsearch.index.translog.TranslogCorruptedException.class, 48); + ids.put(org.elasticsearch.cluster.block.ClusterBlockException.class, 49); + ids.put(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, 50); + ids.put(org.elasticsearch.index.IndexShardAlreadyExistsException.class, 51); + ids.put(org.elasticsearch.index.engine.VersionConflictEngineException.class, 52); + ids.put(org.elasticsearch.index.engine.EngineException.class, 53); + ids.put(org.elasticsearch.index.engine.DocumentAlreadyExistsException.class, 54); + ids.put(org.elasticsearch.action.NoSuchNodeException.class, 55); + ids.put(org.elasticsearch.common.settings.SettingsException.class, 56); + ids.put(org.elasticsearch.indices.IndexTemplateMissingException.class, 57); + ids.put(org.elasticsearch.transport.SendRequestTransportException.class, 58); + ids.put(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, 59); + ids.put(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, 60); + ids.put(org.elasticsearch.cluster.routing.RoutingValidationException.class, 61); + ids.put(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, 62); + ids.put(org.elasticsearch.indices.AliasFilterParsingException.class, 63); + ids.put(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class, 64); + ids.put(org.elasticsearch.gateway.GatewayException.class, 65); + ids.put(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, 66); + ids.put(org.elasticsearch.http.HttpException.class, 67); + ids.put(org.elasticsearch.ElasticsearchException.class, 68); + ids.put(org.elasticsearch.snapshots.SnapshotMissingException.class, 69); + ids.put(org.elasticsearch.action.PrimaryMissingActionException.class, 70); + ids.put(org.elasticsearch.action.FailedNodeException.class, 71); + ids.put(org.elasticsearch.search.SearchParseException.class, 72); + ids.put(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, 73); + ids.put(org.elasticsearch.common.blobstore.BlobStoreException.class, 74); + ids.put(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, 75); + ids.put(org.elasticsearch.index.engine.RecoveryEngineException.class, 76); + ids.put(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, 77); + ids.put(org.elasticsearch.action.TimestampParsingException.class, 78); + ids.put(org.elasticsearch.action.RoutingMissingException.class, 79); + ids.put(org.elasticsearch.index.engine.IndexFailedEngineException.class, 80); + ids.put(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, 81); + ids.put(org.elasticsearch.repositories.RepositoryException.class, 82); + ids.put(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, 83); + ids.put(org.elasticsearch.transport.NodeDisconnectedException.class, 84); + ids.put(org.elasticsearch.index.AlreadyExpiredException.class, 85); + ids.put(org.elasticsearch.search.aggregations.AggregationExecutionException.class, 86); + ids.put(org.elasticsearch.index.mapper.MergeMappingException.class, 87); + ids.put(org.elasticsearch.indices.InvalidIndexTemplateException.class, 88); + ids.put(org.elasticsearch.percolator.PercolateException.class, 89); + ids.put(org.elasticsearch.index.engine.RefreshFailedEngineException.class, 90); + ids.put(org.elasticsearch.search.aggregations.AggregationInitializationException.class, 91); + ids.put(org.elasticsearch.indices.recovery.DelayRecoveryException.class, 92); + ids.put(org.elasticsearch.search.warmer.IndexWarmerMissingException.class, 93); + ids.put(org.elasticsearch.client.transport.NoNodeAvailableException.class, 94); + ids.put(org.elasticsearch.script.groovy.GroovyScriptCompilationException.class, 95); + ids.put(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, 96); + ids.put(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, 97); + ids.put(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, 98); + ids.put(org.elasticsearch.index.shard.IndexShardNotStartedException.class, 99); + ids.put(org.elasticsearch.action.search.SearchPhaseExecutionException.class, 100); + ids.put(org.elasticsearch.transport.ActionNotFoundTransportException.class, 101); + ids.put(org.elasticsearch.transport.TransportSerializationException.class, 102); + ids.put(org.elasticsearch.transport.RemoteTransportException.class, 103); + ids.put(org.elasticsearch.index.engine.EngineCreationFailureException.class, 104); + ids.put(org.elasticsearch.cluster.routing.RoutingException.class, 105); + ids.put(org.elasticsearch.index.shard.IndexShardRecoveryException.class, 106); + ids.put(org.elasticsearch.repositories.RepositoryMissingException.class, 107); + ids.put(org.elasticsearch.index.percolator.PercolatorException.class, 108); + ids.put(org.elasticsearch.index.engine.DocumentSourceMissingException.class, 109); + ids.put(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, 110); + ids.put(org.elasticsearch.common.settings.NoClassSettingsException.class, 111); + ids.put(org.elasticsearch.transport.BindTransportException.class, 112); + ids.put(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, 113); + ids.put(org.elasticsearch.index.shard.IndexShardRecoveringException.class, 114); + ids.put(org.elasticsearch.index.translog.TranslogException.class, 115); + ids.put(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, 116); + ids.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, 117); + ids.put(org.elasticsearch.ElasticsearchTimeoutException.class, 118); + ids.put(org.elasticsearch.search.query.QueryPhaseExecutionException.class, 119); + ids.put(org.elasticsearch.repositories.RepositoryVerificationException.class, 120); + ids.put(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, 121); + ids.put(org.elasticsearch.script.groovy.GroovyScriptExecutionException.class, 122); + ids.put(org.elasticsearch.indices.IndexAlreadyExistsException.class, 123); + ids.put(org.elasticsearch.script.Script.ScriptParseException.class, 124); + ids.put(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, 125); + ids.put(org.elasticsearch.index.mapper.MapperParsingException.class, 126); + ids.put(org.elasticsearch.search.SearchContextException.class, 127); + ids.put(org.elasticsearch.search.builder.SearchSourceBuilderException.class, 128); + ids.put(org.elasticsearch.index.engine.EngineClosedException.class, 129); + ids.put(org.elasticsearch.action.NoShardAvailableActionException.class, 130); + ids.put(org.elasticsearch.action.UnavailableShardsException.class, 131); + ids.put(org.elasticsearch.index.engine.FlushFailedEngineException.class, 132); + ids.put(org.elasticsearch.common.breaker.CircuitBreakingException.class, 133); + ids.put(org.elasticsearch.transport.NodeNotConnectedException.class, 134); + ids.put(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, 135); + ids.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, 136); + ids.put(org.elasticsearch.indices.TypeMissingException.class, 137); + ids.put(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, 138); + ids.put(org.elasticsearch.index.query.QueryShardException.class, 139); + + for (ElasticsearchException.ElasticsearchExceptionHandle handle : ElasticsearchException.ElasticsearchExceptionHandle.values()) { + assertEquals((int)ids.get(handle.exceptionClass), handle.id); + } + + for (Map.Entry, Integer> entry : ids.entrySet()) { + assertEquals((int)entry.getValue(), ElasticsearchException.getId(entry.getKey())); + } + } } From ab19bfbe9b6edc9c907a6af20a256ef50bcb2e0f Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 25 Sep 2015 14:43:40 -0400 Subject: [PATCH 3/4] Removing and reordering ElasticsearchExceptions should be okay --- .../java/org/elasticsearch/ElasticsearchException.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index 7422ab7834d..d9ac0003a8e 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -47,7 +47,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte private static final String RESOURCE_HEADER_TYPE_KEY = "es.resource.type"; private static final String RESOURCE_HEADER_ID_KEY = "es.resource.id"; - private static final FunctionThatThrowsIOException[] ID_TO_SUPPLIER; + private static final Map> ID_TO_SUPPLIER; private static final Map, ElasticsearchExceptionHandle> CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE; private final Map> headers = new HashMap<>(); @@ -231,7 +231,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte } public static ElasticsearchException readException(StreamInput input, int id) throws IOException { - FunctionThatThrowsIOException elasticsearchException = ID_TO_SUPPLIER[id]; + FunctionThatThrowsIOException elasticsearchException = ID_TO_SUPPLIER.get(id); if (elasticsearchException == null) { throw new IllegalStateException("unknown exception for id: " + id); } @@ -613,11 +613,9 @@ 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)); - FunctionThatThrowsIOException[] idToSupplier = new FunctionThatThrowsIOException[exceptions.size()]; - exceptions.entrySet().forEach(e -> idToSupplier[e.getValue().id] = e.getValue().constructor); - - ID_TO_SUPPLIER = idToSupplier; + ID_TO_SUPPLIER = Collections.unmodifiableMap(idToSupplier); CLASS_TO_ELASTICSEARCH_EXCEPTION_HANDLE = Collections.unmodifiableMap(exceptions); } From 75ecc54f33b8ce8f46fb90d785cf38de113f354e Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 25 Sep 2015 14:54:29 -0400 Subject: [PATCH 4/4] Add clarifying comment on removing an ElasticsearchException --- .../elasticsearch/ElasticsearchException.java | 5 +- .../ExceptionSerializationTests.java | 299 +++++++++--------- 2 files changed, 157 insertions(+), 147 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index d9ac0003a8e..4804dd56b11 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -454,11 +454,12 @@ public class ElasticsearchException extends RuntimeException implements ToXConte } enum ElasticsearchExceptionHandle { - // each exception gets an ordinal assigned that must never change. While the exception name can + // 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. - // NOTE: ONLY APPEND TO THE END and NEVER REMOVE EXCEPTIONS IN MINOR VERSIONS + // 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), diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index b0e8c19ebf1..2ad930e67ba 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -656,154 +656,163 @@ public class ExceptionSerializationTests extends ESTestCase { } public void testIds() { - Map, Integer> ids = new HashMap<>(); - ids.put(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, 0); - ids.put(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, 1); - ids.put(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, 2); - ids.put(org.elasticsearch.discovery.MasterNotDiscoveredException.class, 3); - ids.put(org.elasticsearch.ElasticsearchSecurityException.class, 4); - ids.put(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, 5); - ids.put(org.elasticsearch.indices.IndexClosedException.class, 6); - ids.put(org.elasticsearch.http.BindHttpException.class, 7); - ids.put(org.elasticsearch.action.search.ReduceSearchPhaseException.class, 8); - ids.put(org.elasticsearch.node.NodeClosedException.class, 9); - ids.put(org.elasticsearch.index.engine.SnapshotFailedEngineException.class, 10); - ids.put(org.elasticsearch.index.shard.ShardNotFoundException.class, 11); - ids.put(org.elasticsearch.transport.ConnectTransportException.class, 12); - ids.put(org.elasticsearch.transport.NotSerializableTransportException.class, 13); - ids.put(org.elasticsearch.transport.ResponseHandlerFailureTransportException.class, 14); - ids.put(org.elasticsearch.indices.IndexCreationException.class, 15); - ids.put(org.elasticsearch.index.IndexNotFoundException.class, 16); - ids.put(org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class, 17); - ids.put(org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class, 18); - ids.put(org.elasticsearch.ResourceNotFoundException.class, 19); - ids.put(org.elasticsearch.transport.ActionTransportException.class, 20); - ids.put(org.elasticsearch.ElasticsearchGenerationException.class, 21); - ids.put(org.elasticsearch.index.engine.CreateFailedEngineException.class, 22); - ids.put(org.elasticsearch.index.shard.IndexShardStartedException.class, 23); - ids.put(org.elasticsearch.search.SearchContextMissingException.class, 24); - ids.put(org.elasticsearch.script.ScriptException.class, 25); - ids.put(org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class, 26); - ids.put(org.elasticsearch.snapshots.SnapshotCreationException.class, 27); - ids.put(org.elasticsearch.index.engine.DeleteFailedEngineException.class, 28); - ids.put(org.elasticsearch.index.engine.DocumentMissingException.class, 29); - ids.put(org.elasticsearch.snapshots.SnapshotException.class, 30); - ids.put(org.elasticsearch.indices.InvalidAliasNameException.class, 31); - ids.put(org.elasticsearch.indices.InvalidIndexNameException.class, 32); - ids.put(org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class, 33); - ids.put(org.elasticsearch.transport.TransportException.class, 34); - ids.put(org.elasticsearch.ElasticsearchParseException.class, 35); - ids.put(org.elasticsearch.search.SearchException.class, 36); - ids.put(org.elasticsearch.index.mapper.MapperException.class, 37); - ids.put(org.elasticsearch.indices.InvalidTypeNameException.class, 38); - ids.put(org.elasticsearch.snapshots.SnapshotRestoreException.class, 39); - ids.put(org.elasticsearch.common.ParsingException.class, 40); - ids.put(org.elasticsearch.index.shard.IndexShardClosedException.class, 41); - ids.put(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class, 42); - ids.put(org.elasticsearch.index.translog.TruncatedTranslogException.class, 43); - ids.put(org.elasticsearch.indices.recovery.RecoveryFailedException.class, 44); - ids.put(org.elasticsearch.index.shard.IndexShardRelocatedException.class, 45); - ids.put(org.elasticsearch.transport.NodeShouldNotConnectException.class, 46); - ids.put(org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class, 47); - ids.put(org.elasticsearch.index.translog.TranslogCorruptedException.class, 48); - ids.put(org.elasticsearch.cluster.block.ClusterBlockException.class, 49); - ids.put(org.elasticsearch.search.fetch.FetchPhaseExecutionException.class, 50); - ids.put(org.elasticsearch.index.IndexShardAlreadyExistsException.class, 51); - ids.put(org.elasticsearch.index.engine.VersionConflictEngineException.class, 52); - ids.put(org.elasticsearch.index.engine.EngineException.class, 53); - ids.put(org.elasticsearch.index.engine.DocumentAlreadyExistsException.class, 54); - ids.put(org.elasticsearch.action.NoSuchNodeException.class, 55); - ids.put(org.elasticsearch.common.settings.SettingsException.class, 56); - ids.put(org.elasticsearch.indices.IndexTemplateMissingException.class, 57); - ids.put(org.elasticsearch.transport.SendRequestTransportException.class, 58); - ids.put(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class, 59); - ids.put(org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class, 60); - ids.put(org.elasticsearch.cluster.routing.RoutingValidationException.class, 61); - ids.put(org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class, 62); - ids.put(org.elasticsearch.indices.AliasFilterParsingException.class, 63); - ids.put(org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class, 64); - ids.put(org.elasticsearch.gateway.GatewayException.class, 65); - ids.put(org.elasticsearch.index.shard.IndexShardNotRecoveringException.class, 66); - ids.put(org.elasticsearch.http.HttpException.class, 67); - ids.put(org.elasticsearch.ElasticsearchException.class, 68); - ids.put(org.elasticsearch.snapshots.SnapshotMissingException.class, 69); - ids.put(org.elasticsearch.action.PrimaryMissingActionException.class, 70); - ids.put(org.elasticsearch.action.FailedNodeException.class, 71); - ids.put(org.elasticsearch.search.SearchParseException.class, 72); - ids.put(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class, 73); - ids.put(org.elasticsearch.common.blobstore.BlobStoreException.class, 74); - ids.put(org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class, 75); - ids.put(org.elasticsearch.index.engine.RecoveryEngineException.class, 76); - ids.put(org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class, 77); - ids.put(org.elasticsearch.action.TimestampParsingException.class, 78); - ids.put(org.elasticsearch.action.RoutingMissingException.class, 79); - ids.put(org.elasticsearch.index.engine.IndexFailedEngineException.class, 80); - ids.put(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class, 81); - ids.put(org.elasticsearch.repositories.RepositoryException.class, 82); - ids.put(org.elasticsearch.transport.ReceiveTimeoutTransportException.class, 83); - ids.put(org.elasticsearch.transport.NodeDisconnectedException.class, 84); - ids.put(org.elasticsearch.index.AlreadyExpiredException.class, 85); - ids.put(org.elasticsearch.search.aggregations.AggregationExecutionException.class, 86); - ids.put(org.elasticsearch.index.mapper.MergeMappingException.class, 87); - ids.put(org.elasticsearch.indices.InvalidIndexTemplateException.class, 88); - ids.put(org.elasticsearch.percolator.PercolateException.class, 89); - ids.put(org.elasticsearch.index.engine.RefreshFailedEngineException.class, 90); - ids.put(org.elasticsearch.search.aggregations.AggregationInitializationException.class, 91); - ids.put(org.elasticsearch.indices.recovery.DelayRecoveryException.class, 92); - ids.put(org.elasticsearch.search.warmer.IndexWarmerMissingException.class, 93); - ids.put(org.elasticsearch.client.transport.NoNodeAvailableException.class, 94); - ids.put(org.elasticsearch.script.groovy.GroovyScriptCompilationException.class, 95); - ids.put(org.elasticsearch.snapshots.InvalidSnapshotNameException.class, 96); - ids.put(org.elasticsearch.index.shard.IllegalIndexShardStateException.class, 97); - ids.put(org.elasticsearch.index.snapshots.IndexShardSnapshotException.class, 98); - ids.put(org.elasticsearch.index.shard.IndexShardNotStartedException.class, 99); - ids.put(org.elasticsearch.action.search.SearchPhaseExecutionException.class, 100); - ids.put(org.elasticsearch.transport.ActionNotFoundTransportException.class, 101); - ids.put(org.elasticsearch.transport.TransportSerializationException.class, 102); - ids.put(org.elasticsearch.transport.RemoteTransportException.class, 103); - ids.put(org.elasticsearch.index.engine.EngineCreationFailureException.class, 104); - ids.put(org.elasticsearch.cluster.routing.RoutingException.class, 105); - ids.put(org.elasticsearch.index.shard.IndexShardRecoveryException.class, 106); - ids.put(org.elasticsearch.repositories.RepositoryMissingException.class, 107); - ids.put(org.elasticsearch.index.percolator.PercolatorException.class, 108); - ids.put(org.elasticsearch.index.engine.DocumentSourceMissingException.class, 109); - ids.put(org.elasticsearch.index.engine.FlushNotAllowedEngineException.class, 110); - ids.put(org.elasticsearch.common.settings.NoClassSettingsException.class, 111); - ids.put(org.elasticsearch.transport.BindTransportException.class, 112); - ids.put(org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class, 113); - ids.put(org.elasticsearch.index.shard.IndexShardRecoveringException.class, 114); - ids.put(org.elasticsearch.index.translog.TranslogException.class, 115); - ids.put(org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class, 116); - ids.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class, 117); - ids.put(org.elasticsearch.ElasticsearchTimeoutException.class, 118); - ids.put(org.elasticsearch.search.query.QueryPhaseExecutionException.class, 119); - ids.put(org.elasticsearch.repositories.RepositoryVerificationException.class, 120); - ids.put(org.elasticsearch.search.aggregations.InvalidAggregationPathException.class, 121); - ids.put(org.elasticsearch.script.groovy.GroovyScriptExecutionException.class, 122); - ids.put(org.elasticsearch.indices.IndexAlreadyExistsException.class, 123); - ids.put(org.elasticsearch.script.Script.ScriptParseException.class, 124); - ids.put(org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class, 125); - ids.put(org.elasticsearch.index.mapper.MapperParsingException.class, 126); - ids.put(org.elasticsearch.search.SearchContextException.class, 127); - ids.put(org.elasticsearch.search.builder.SearchSourceBuilderException.class, 128); - ids.put(org.elasticsearch.index.engine.EngineClosedException.class, 129); - ids.put(org.elasticsearch.action.NoShardAvailableActionException.class, 130); - ids.put(org.elasticsearch.action.UnavailableShardsException.class, 131); - ids.put(org.elasticsearch.index.engine.FlushFailedEngineException.class, 132); - ids.put(org.elasticsearch.common.breaker.CircuitBreakingException.class, 133); - ids.put(org.elasticsearch.transport.NodeNotConnectedException.class, 134); - ids.put(org.elasticsearch.index.mapper.StrictDynamicMappingException.class, 135); - ids.put(org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class, 136); - ids.put(org.elasticsearch.indices.TypeMissingException.class, 137); - ids.put(org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class, 138); - ids.put(org.elasticsearch.index.query.QueryShardException.class, 139); + Map> ids = new HashMap<>(); + ids.put(0, org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class); + ids.put(1, org.elasticsearch.search.dfs.DfsPhaseExecutionException.class); + ids.put(2, org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class); + ids.put(3, org.elasticsearch.discovery.MasterNotDiscoveredException.class); + ids.put(4, org.elasticsearch.ElasticsearchSecurityException.class); + ids.put(5, org.elasticsearch.index.snapshots.IndexShardRestoreException.class); + ids.put(6, org.elasticsearch.indices.IndexClosedException.class); + ids.put(7, org.elasticsearch.http.BindHttpException.class); + ids.put(8, org.elasticsearch.action.search.ReduceSearchPhaseException.class); + ids.put(9, org.elasticsearch.node.NodeClosedException.class); + ids.put(10, org.elasticsearch.index.engine.SnapshotFailedEngineException.class); + ids.put(11, org.elasticsearch.index.shard.ShardNotFoundException.class); + ids.put(12, org.elasticsearch.transport.ConnectTransportException.class); + ids.put(13, org.elasticsearch.transport.NotSerializableTransportException.class); + ids.put(14, org.elasticsearch.transport.ResponseHandlerFailureTransportException.class); + ids.put(15, org.elasticsearch.indices.IndexCreationException.class); + ids.put(16, org.elasticsearch.index.IndexNotFoundException.class); + ids.put(17, org.elasticsearch.cluster.routing.IllegalShardRoutingStateException.class); + ids.put(18, org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException.class); + ids.put(19, org.elasticsearch.ResourceNotFoundException.class); + ids.put(20, org.elasticsearch.transport.ActionTransportException.class); + ids.put(21, org.elasticsearch.ElasticsearchGenerationException.class); + ids.put(22, org.elasticsearch.index.engine.CreateFailedEngineException.class); + ids.put(23, org.elasticsearch.index.shard.IndexShardStartedException.class); + ids.put(24, org.elasticsearch.search.SearchContextMissingException.class); + ids.put(25, org.elasticsearch.script.ScriptException.class); + ids.put(26, org.elasticsearch.index.shard.TranslogRecoveryPerformer.BatchOperationException.class); + ids.put(27, org.elasticsearch.snapshots.SnapshotCreationException.class); + ids.put(28, org.elasticsearch.index.engine.DeleteFailedEngineException.class); + ids.put(29, org.elasticsearch.index.engine.DocumentMissingException.class); + ids.put(30, org.elasticsearch.snapshots.SnapshotException.class); + ids.put(31, org.elasticsearch.indices.InvalidAliasNameException.class); + ids.put(32, org.elasticsearch.indices.InvalidIndexNameException.class); + ids.put(33, org.elasticsearch.indices.IndexPrimaryShardNotAllocatedException.class); + ids.put(34, org.elasticsearch.transport.TransportException.class); + ids.put(35, org.elasticsearch.ElasticsearchParseException.class); + ids.put(36, org.elasticsearch.search.SearchException.class); + ids.put(37, org.elasticsearch.index.mapper.MapperException.class); + ids.put(38, org.elasticsearch.indices.InvalidTypeNameException.class); + ids.put(39, org.elasticsearch.snapshots.SnapshotRestoreException.class); + ids.put(40, org.elasticsearch.common.ParsingException.class); + ids.put(41, org.elasticsearch.index.shard.IndexShardClosedException.class); + ids.put(42, org.elasticsearch.indices.recovery.RecoverFilesRecoveryException.class); + ids.put(43, org.elasticsearch.index.translog.TruncatedTranslogException.class); + ids.put(44, org.elasticsearch.indices.recovery.RecoveryFailedException.class); + ids.put(45, org.elasticsearch.index.shard.IndexShardRelocatedException.class); + ids.put(46, org.elasticsearch.transport.NodeShouldNotConnectException.class); + ids.put(47, org.elasticsearch.indices.IndexTemplateAlreadyExistsException.class); + ids.put(48, org.elasticsearch.index.translog.TranslogCorruptedException.class); + ids.put(49, org.elasticsearch.cluster.block.ClusterBlockException.class); + ids.put(50, org.elasticsearch.search.fetch.FetchPhaseExecutionException.class); + ids.put(51, org.elasticsearch.index.IndexShardAlreadyExistsException.class); + ids.put(52, org.elasticsearch.index.engine.VersionConflictEngineException.class); + ids.put(53, org.elasticsearch.index.engine.EngineException.class); + ids.put(54, org.elasticsearch.index.engine.DocumentAlreadyExistsException.class); + ids.put(55, org.elasticsearch.action.NoSuchNodeException.class); + ids.put(56, org.elasticsearch.common.settings.SettingsException.class); + ids.put(57, org.elasticsearch.indices.IndexTemplateMissingException.class); + ids.put(58, org.elasticsearch.transport.SendRequestTransportException.class); + ids.put(59, org.elasticsearch.common.util.concurrent.EsRejectedExecutionException.class); + ids.put(60, org.elasticsearch.common.lucene.Lucene.EarlyTerminationException.class); + ids.put(61, org.elasticsearch.cluster.routing.RoutingValidationException.class); + ids.put(62, org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class); + ids.put(63, org.elasticsearch.indices.AliasFilterParsingException.class); + ids.put(64, org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class); + ids.put(65, org.elasticsearch.gateway.GatewayException.class); + ids.put(66, org.elasticsearch.index.shard.IndexShardNotRecoveringException.class); + ids.put(67, org.elasticsearch.http.HttpException.class); + ids.put(68, org.elasticsearch.ElasticsearchException.class); + ids.put(69, org.elasticsearch.snapshots.SnapshotMissingException.class); + ids.put(70, org.elasticsearch.action.PrimaryMissingActionException.class); + ids.put(71, org.elasticsearch.action.FailedNodeException.class); + ids.put(72, org.elasticsearch.search.SearchParseException.class); + ids.put(73, org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException.class); + ids.put(74, org.elasticsearch.common.blobstore.BlobStoreException.class); + ids.put(75, org.elasticsearch.cluster.IncompatibleClusterStateVersionException.class); + ids.put(76, org.elasticsearch.index.engine.RecoveryEngineException.class); + ids.put(77, org.elasticsearch.common.util.concurrent.UncategorizedExecutionException.class); + ids.put(78, org.elasticsearch.action.TimestampParsingException.class); + ids.put(79, org.elasticsearch.action.RoutingMissingException.class); + ids.put(80, org.elasticsearch.index.engine.IndexFailedEngineException.class); + ids.put(81, org.elasticsearch.index.snapshots.IndexShardRestoreFailedException.class); + ids.put(82, org.elasticsearch.repositories.RepositoryException.class); + ids.put(83, org.elasticsearch.transport.ReceiveTimeoutTransportException.class); + ids.put(84, org.elasticsearch.transport.NodeDisconnectedException.class); + ids.put(85, org.elasticsearch.index.AlreadyExpiredException.class); + ids.put(86, org.elasticsearch.search.aggregations.AggregationExecutionException.class); + ids.put(87, org.elasticsearch.index.mapper.MergeMappingException.class); + ids.put(88, org.elasticsearch.indices.InvalidIndexTemplateException.class); + ids.put(89, org.elasticsearch.percolator.PercolateException.class); + ids.put(90, org.elasticsearch.index.engine.RefreshFailedEngineException.class); + ids.put(91, org.elasticsearch.search.aggregations.AggregationInitializationException.class); + ids.put(92, org.elasticsearch.indices.recovery.DelayRecoveryException.class); + ids.put(93, org.elasticsearch.search.warmer.IndexWarmerMissingException.class); + ids.put(94, org.elasticsearch.client.transport.NoNodeAvailableException.class); + ids.put(95, org.elasticsearch.script.groovy.GroovyScriptCompilationException.class); + ids.put(96, org.elasticsearch.snapshots.InvalidSnapshotNameException.class); + ids.put(97, org.elasticsearch.index.shard.IllegalIndexShardStateException.class); + ids.put(98, org.elasticsearch.index.snapshots.IndexShardSnapshotException.class); + ids.put(99, org.elasticsearch.index.shard.IndexShardNotStartedException.class); + ids.put(100, org.elasticsearch.action.search.SearchPhaseExecutionException.class); + ids.put(101, org.elasticsearch.transport.ActionNotFoundTransportException.class); + ids.put(102, org.elasticsearch.transport.TransportSerializationException.class); + ids.put(103, org.elasticsearch.transport.RemoteTransportException.class); + ids.put(104, org.elasticsearch.index.engine.EngineCreationFailureException.class); + ids.put(105, org.elasticsearch.cluster.routing.RoutingException.class); + ids.put(106, org.elasticsearch.index.shard.IndexShardRecoveryException.class); + ids.put(107, org.elasticsearch.repositories.RepositoryMissingException.class); + ids.put(108, org.elasticsearch.index.percolator.PercolatorException.class); + ids.put(109, org.elasticsearch.index.engine.DocumentSourceMissingException.class); + ids.put(110, org.elasticsearch.index.engine.FlushNotAllowedEngineException.class); + ids.put(111, org.elasticsearch.common.settings.NoClassSettingsException.class); + ids.put(112, org.elasticsearch.transport.BindTransportException.class); + ids.put(113, org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesNotFoundException.class); + ids.put(114, org.elasticsearch.index.shard.IndexShardRecoveringException.class); + ids.put(115, org.elasticsearch.index.translog.TranslogException.class); + ids.put(116, org.elasticsearch.cluster.metadata.ProcessClusterEventTimeoutException.class); + ids.put(117, org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnPrimaryException.class); + ids.put(118, org.elasticsearch.ElasticsearchTimeoutException.class); + ids.put(119, org.elasticsearch.search.query.QueryPhaseExecutionException.class); + ids.put(120, org.elasticsearch.repositories.RepositoryVerificationException.class); + ids.put(121, org.elasticsearch.search.aggregations.InvalidAggregationPathException.class); + ids.put(122, org.elasticsearch.script.groovy.GroovyScriptExecutionException.class); + ids.put(123, org.elasticsearch.indices.IndexAlreadyExistsException.class); + ids.put(124, org.elasticsearch.script.Script.ScriptParseException.class); + ids.put(125, org.elasticsearch.transport.netty.SizeHeaderFrameDecoder.HttpOnTransportException.class); + ids.put(126, org.elasticsearch.index.mapper.MapperParsingException.class); + ids.put(127, org.elasticsearch.search.SearchContextException.class); + ids.put(128, org.elasticsearch.search.builder.SearchSourceBuilderException.class); + ids.put(129, org.elasticsearch.index.engine.EngineClosedException.class); + ids.put(130, org.elasticsearch.action.NoShardAvailableActionException.class); + ids.put(131, org.elasticsearch.action.UnavailableShardsException.class); + ids.put(132, org.elasticsearch.index.engine.FlushFailedEngineException.class); + ids.put(133, org.elasticsearch.common.breaker.CircuitBreakingException.class); + ids.put(134, org.elasticsearch.transport.NodeNotConnectedException.class); + ids.put(135, org.elasticsearch.index.mapper.StrictDynamicMappingException.class); + ids.put(136, org.elasticsearch.action.support.replication.TransportReplicationAction.RetryOnReplicaException.class); + ids.put(137, org.elasticsearch.indices.TypeMissingException.class); + ids.put(138, org.elasticsearch.discovery.Discovery.FailedToCommitClusterStateException.class); + ids.put(139, org.elasticsearch.index.query.QueryShardException.class); - for (ElasticsearchException.ElasticsearchExceptionHandle handle : ElasticsearchException.ElasticsearchExceptionHandle.values()) { - assertEquals((int)ids.get(handle.exceptionClass), handle.id); + Map, Integer> reverse = new HashMap<>(); + for (Map.Entry> entry : ids.entrySet()) { + if (entry.getValue() != null) { + reverse.put(entry.getValue(), entry.getKey()); + } } - for (Map.Entry, Integer> entry : ids.entrySet()) { - assertEquals((int)entry.getValue(), ElasticsearchException.getId(entry.getKey())); + for (ElasticsearchException.ElasticsearchExceptionHandle handle : ElasticsearchException.ElasticsearchExceptionHandle.values()) { + assertEquals((int)reverse.get(handle.exceptionClass), handle.id); + } + + for (Map.Entry> entry : ids.entrySet()) { + if (entry.getValue() != null) { + assertEquals((int) entry.getKey(), ElasticsearchException.getId(entry.getValue())); + } } } }