Class ProtocolException

All Implemented Interfaces:
Serializable

public class ProtocolException extends RuntimeException
Exception thrown when protocol data is malformed or exceeds defined limits. Used for both read-side validation (untrusted input) and write-side validation (defense in depth).
See Also:
  • Constructor Details

    • ProtocolException

      public ProtocolException(@Nonnull String message)
    • ProtocolException

      public ProtocolException(@Nonnull String message, @Nonnull Throwable cause)
  • Method Details

    • arrayTooLong

      @Nonnull public static ProtocolException arrayTooLong(@Nonnull String fieldName, int actual, int max)
      Creates an exception for array length exceeding the maximum allowed.
    • stringTooLong

      @Nonnull public static ProtocolException stringTooLong(@Nonnull String fieldName, int actual, int max)
      Creates an exception for string length exceeding the maximum allowed.
    • dictionaryTooLarge

      @Nonnull public static ProtocolException dictionaryTooLarge(@Nonnull String fieldName, int actual, int max)
      Creates an exception for dictionary count exceeding the maximum allowed.
    • bufferTooSmall

      @Nonnull public static ProtocolException bufferTooSmall(@Nonnull String fieldName, int required, int available)
      Creates an exception for buffer being too small to read the expected data.
    • invalidVarInt

      @Nonnull public static ProtocolException invalidVarInt(@Nonnull String fieldName)
      Creates an exception for invalid VarInt encoding.
    • nonAdvancingEntry

      @Nonnull public static ProtocolException nonAdvancingEntry(@Nonnull String fieldName, int offset)
      Creates an exception for a collection entry that consumes no bytes.
    • invalidOffset

      @Nonnull public static ProtocolException invalidOffset(@Nonnull String fieldName, int offset, int bufferLength)
      Creates an exception for invalid offset values.
    • nonCanonicalLayout

      @Nonnull public static ProtocolException nonCanonicalLayout(@Nonnull String fieldName, int actual, int expected)
      A writer lays the variable block out contiguously in field order, so a present field's offset slot equals the end of the previous one and an absent field's slot is -1. Element loops advance by the re-encoded size, which only equals the occupied span while that holds.
    • unknownPolymorphicType

      @Nonnull public static ProtocolException unknownPolymorphicType(@Nonnull String typeName, int typeId)
      Creates an exception for unknown polymorphic type ID.
    • nestingTooDeep

      @Nonnull public static ProtocolException nestingTooDeep(@Nonnull String typeName, int max)
      Creates an exception for a value nested deeper than the decoder allows.
    • duplicateKey

      @Nonnull public static ProtocolException duplicateKey(@Nonnull String fieldName, @Nonnull Object key)
      Creates an exception for duplicate dictionary key.
    • invalidEnumValue

      @Nonnull public static ProtocolException invalidEnumValue(@Nonnull String enumName, int value)
      Creates an exception for invalid enum value.
    • arrayTooShort

      @Nonnull public static ProtocolException arrayTooShort(@Nonnull String fieldName, int actual, int min)
      Creates an exception for array length below the minimum required.
    • stringTooShort

      @Nonnull public static ProtocolException stringTooShort(@Nonnull String fieldName, int actual, int min)
      Creates an exception for string length below the minimum required.
    • dictionaryTooSmall

      @Nonnull public static ProtocolException dictionaryTooSmall(@Nonnull String fieldName, int actual, int min)
      Creates an exception for dictionary count below the minimum required.
    • valueOutOfRange

      @Nonnull public static ProtocolException valueOutOfRange(@Nonnull String fieldName, @Nonnull Object value, double min, double max)
      Creates an exception for numeric value outside the allowed range.
    • valueBelowMinimum

      @Nonnull public static ProtocolException valueBelowMinimum(@Nonnull String fieldName, @Nonnull Object value, double min)
      Creates an exception for numeric value below the minimum.
    • valueAboveMaximum

      @Nonnull public static ProtocolException valueAboveMaximum(@Nonnull String fieldName, @Nonnull Object value, double max)
      Creates an exception for numeric value above the maximum.
    • invalidAsciiString

      @Nonnull public static ProtocolException invalidAsciiString(@Nonnull String fieldName)
      Creates an exception for a string containing non-ASCII bytes.
    • malformedString

      @Nonnull public static ProtocolException malformedString(@Nonnull String fieldName)
      Creates an exception for a string whose bytes are not well-formed in its declared charset.
    • valueNotFinite

      @Nonnull public static ProtocolException valueNotFinite(@Nonnull String fieldName, @Nonnull Object value)
      Creates an exception for a non-finite (NaN or +/-Infinity) floating-point value.