The wire serialization of exceptions require exceptions to be registered. For instance if the transport node(transport inter-node communication) throws a custom exception, the caller node at transport needs to handle this and throw it appropriately to clients. However I couldn't find a way for plugins to be register the custom exception.
return throwable; } /** * This is the list of Exceptions Elasticsearch can throw over the wire or save into a corruption marker. Each value in the enum is a * single exception tying the Class to an id for use of the encode side and the id back to a constructor for use on the decode side. As * such its ok if the exceptions to change names so long as their constructor can still read the exception. Each exception is listed * in id order below. If you want to remove an exception leave a tombstone comment and mark the id as null in * ExceptionSerializationTests.testIds.ids. */ private enum ElasticsearchExceptionHandle { INDEX_SHARD_SNAPSHOT_FAILED_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException.class, org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException::new, 0, UNKNOWN_VERSION_ADDED), DFS_PHASE_EXECUTION_EXCEPTION(org.elasticsearch.search.dfs.DfsPhaseExecutionException.class, org.elasticsearch.search.dfs.DfsPhaseExecutionException::new, 1, UNKNOWN_VERSION_ADDED), EXECUTION_CANCELLED_EXCEPTION(org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class, org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, 2, UNKNOWN_VERSION_ADDED), MASTER_NOT_DISCOVERED_EXCEPTION(org.elasticsearch.discovery.MasterNotDiscoveredException.class, org.elasticsearch.discovery.MasterNotDiscoveredException::new, 3, UNKNOWN_VERSION_ADDED), ELASTICSEARCH_SECURITY_EXCEPTION(org.elasticsearch.ElasticsearchSecurityException.class, org.elasticsearch.ElasticsearchSecurityException::new, 4, UNKNOWN_VERSION_ADDED),
As a result the exceptions get wrapped in a NotSerializableExceptionWrapper.
Is there a way to handle this effectively or is the expectation/recommendation to unwrap the NotSerializableExceptionWrapper and rethrow the appropriate exception.
import java.io.IOException; /** * This exception can be used to wrap a given, not serializable exception * to serialize via {@link StreamOutput#writeException(Throwable)}. * This class will preserve the stacktrace as well as the suppressed exceptions of * the throwable it was created with instead of it's own. The stacktrace has no indication * of where this exception was created. */ public final class NotSerializableExceptionWrapper extends ElasticsearchException { private final String name; private final RestStatus status; public NotSerializableExceptionWrapper(Throwable other) { super(ElasticsearchException.getExceptionName(other) + ": " + other.getMessage(), other.getCause()); this.name = ElasticsearchException.getExceptionName(other); this.status = ExceptionsHelper.status(other); setStackTrace(other.getStackTrace()); for (Throwable otherSuppressed : other.getSuppressed()) {
system
(system)
Closed
January 18, 2021, 7:37am
2
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.