Class SchemaMismatchException
- Namespace
- Excalibur.Dispatch.Serialization.Avro
- Assembly
- Excalibur.Dispatch.Serialization.Avro.dll
Thrown when an Avro payload's writer-schema fingerprint does not match the reader's schema and no compatible writer schema can be resolved, so the payload cannot be decoded safely.
public sealed class SchemaMismatchException : ApiException, ISerializable
- Inheritance
-
SchemaMismatchException
- Implements
- Inherited Members
- Extension Methods
Remarks
Apache Avro binary is not self-describing: correct decoding requires the writer schema. The base
AvroSerializer frames every payload with the Avro single-object-encoding header
(0xC3 0x01 + the 8-byte little-endian CRC-64-AVRO Rabin fingerprint of the writer schema).
On read, a writer/reader fingerprint mismatch with no resolvable writer schema is a
fail-closed condition: the serializer throws this exception instead of positionally
decoding against the wrong schema (which would silently corrupt field values).
This is the structural guarantee behind "no silent corruption on version skew" — a skew is detected and rejected loudly, never mis-decoded.
Constructors
SchemaMismatchException()
Initializes a new instance of the SchemaMismatchException class.
public SchemaMismatchException()
SchemaMismatchException(string)
Initializes a new instance of the SchemaMismatchException class.
public SchemaMismatchException(string message)
Parameters
messagestringThe message that describes the error.
SchemaMismatchException(string, Exception)
Initializes a new instance of the SchemaMismatchException class.
public SchemaMismatchException(string message, Exception innerException)
Parameters
messagestringThe message that describes the error.
innerExceptionExceptionThe exception that is the cause of the current exception.
Properties
ReaderFingerprint
Gets the reader-schema fingerprint, if available.
public long? ReaderFingerprint { get; init; }
Property Value
- long?
The CRC-64-AVRO Rabin fingerprint of the reader schema.
TargetType
Gets the type that was being deserialized when the mismatch was detected.
public Type? TargetType { get; init; }
Property Value
WriterFingerprint
Gets the writer-schema fingerprint carried by the payload, if available.
public long? WriterFingerprint { get; init; }
Property Value
- long?
The CRC-64-AVRO Rabin fingerprint of the writer schema.
Methods
MissingHeader(Type)
Creates a SchemaMismatchException for a payload missing the Avro single-object header.
public static SchemaMismatchException MissingHeader(Type type)
Parameters
typeTypeThe reader type.
Returns
- SchemaMismatchException
A new SchemaMismatchException instance.
Skew(Type, long, long)
Creates a SchemaMismatchException for a writer/reader fingerprint skew.
public static SchemaMismatchException Skew(Type type, long writerFingerprint, long readerFingerprint)
Parameters
typeTypeThe reader type.
writerFingerprintlongThe writer-schema fingerprint from the payload.
readerFingerprintlongThe reader-schema fingerprint.
Returns
- SchemaMismatchException
A new SchemaMismatchException instance.