Class DeserializationException

  • All Implemented Interfaces:
    java.io.Serializable

    public class DeserializationException
    extends KafkaException
    Exception returned in the consumer record value or key when a deserialization failure occurs.
    Since:
    2.2
    Author:
    Gary Russell, Artem Bilan
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DeserializationException​(java.lang.String message, byte[] data, boolean isKey, java.lang.Throwable cause)
      Construct an instance with the provided properties.
      DeserializationException​(java.lang.String message, org.apache.kafka.common.header.Headers headers, byte[] data, boolean isKey, java.lang.Throwable cause)
      Deprecated.
      Headers are not set during construction.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getData()
      Get the data that failed deserialization (value or key).
      org.apache.kafka.common.header.Headers getHeaders()
      Get the headers.
      boolean isKey()
      True if deserialization of the key failed, otherwise deserialization of the value failed.
      void setHeaders​(org.apache.kafka.common.header.Headers headers)
      Set the headers.
      • Methods inherited from class org.springframework.core.NestedRuntimeException

        contains, getMessage, getMostSpecificCause, getRootCause
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DeserializationException

        public DeserializationException​(java.lang.String message,
                                        byte[] data,
                                        boolean isKey,
                                        java.lang.Throwable cause)
        Construct an instance with the provided properties.
        Parameters:
        message - the message.
        data - the data (value or key).
        isKey - true if the exception occurred while deserializing the key.
        cause - the cause.
      • DeserializationException

        @Deprecated
        public DeserializationException​(java.lang.String message,
                                        @Nullable
                                        org.apache.kafka.common.header.Headers headers,
                                        byte[] data,
                                        boolean isKey,
                                        java.lang.Throwable cause)
        Deprecated.
        Headers are not set during construction.
        Construct an instance with the provided properties.
        Parameters:
        message - the message.
        headers - the headers.
        data - the data (value or key).
        isKey - true if the exception occurred while deserializing the key.
        cause - the cause.
    • Method Detail

      • getHeaders

        @Nullable
        public org.apache.kafka.common.header.Headers getHeaders()
        Get the headers.
        Returns:
        the headers.
      • setHeaders

        public void setHeaders​(@Nullable
                               org.apache.kafka.common.header.Headers headers)
        Set the headers.
        Parameters:
        headers - the headers.
      • getData

        public byte[] getData()
        Get the data that failed deserialization (value or key).
        Returns:
        the data.
      • isKey

        public boolean isKey()
        True if deserialization of the key failed, otherwise deserialization of the value failed.
        Returns:
        true for the key.