Record Class OdysseyResult

java.lang.Object
java.lang.Record
io.confluent.kafka.odyssey.OdysseyResult

public record OdysseyResult(boolean isSuccess, int errorCode, short kafkaErrorCode, Optional<String> errorMessage, boolean isIdempotent, Optional<AssociationConfig> keyAssociation, Optional<AssociationConfig> valueAssociation) extends Record
Result of any Odyssey operation (validation, association creation, fetch, etc.).

This class encapsulates the outcome of interactions with the Odyssey/Schema Registry service, including success/failure status, error codes, messages, and optionally fetched association data.

For mutation operations (validate, createAssociations), only success/failure and error fields are populated — association data fields remain empty. For read operations (fetchAssociations), successful results include the fetched key/value association data.

  • Constructor Details

    • OdysseyResult

      public OdysseyResult(boolean isSuccess, int errorCode, short kafkaErrorCode, Optional<String> errorMessage, boolean isIdempotent, Optional<AssociationConfig> keyAssociation, Optional<AssociationConfig> valueAssociation)
      Creates an instance of a OdysseyResult record class.
      Parameters:
      isSuccess - the value for the isSuccess record component
      errorCode - the value for the errorCode record component
      kafkaErrorCode - the value for the kafkaErrorCode record component
      errorMessage - the value for the errorMessage record component
      isIdempotent - the value for the isIdempotent record component
      keyAssociation - the value for the keyAssociation record component
      valueAssociation - the value for the valueAssociation record component
  • Method Details

    • success

      public static OdysseyResult success()
      Creates a success result (mutation path — no association data).
    • success

      public static OdysseyResult success(boolean isIdempotent)
      Creates a success result with idempotent flag (mutation path).
      Parameters:
      isIdempotent - whether this was an idempotent success (e.g., association already existed)
    • successWithAssociations

      public static OdysseyResult successWithAssociations(Optional<AssociationConfig> keyAssociation, Optional<AssociationConfig> valueAssociation)
      Creates a success result with fetched association data (read path — DescribeConfigs).
      Parameters:
      keyAssociation - the key association if present, or empty
      valueAssociation - the value association if present, or empty
    • failure

      public static OdysseyResult failure(int errorCode, short kafkaErrorCode, String errorMessage)
      Creates a failure result.
      Parameters:
      errorCode - the Odyssey/Schema Registry error code
      kafkaErrorCode - the Kafka protocol error code
      errorMessage - the error message
    • classified

      public static OdysseyResult classified(int srErrorCode, String srMessage)
      Per-topic Schema Registry outcome classified by HTTP-status family (see SchemaErrorClassifier): a 4xx caller fault (e.g. an incompatible schema) keeps the SR-provided message (falling back to the generic INVALID_CONFIG text when SR omits it) and maps to INVALID_CONFIG; a 5xx/server fault redacts the message to the canonical UNKNOWN_SERVER_ERROR text so SR internals never reach the caller. The SR code is preserved in errorCode either way (surfaced via the "Schema Error [<code>]:" prefix); the real cause must be logged by the caller.
    • serverError

      public static OdysseyResult serverError()
    • hasAssociations

      public boolean hasAssociations()
      Returns true if this result contains fetched association data (key or value). Only meaningful for read operations (DescribeConfigs flow).
    • errorMessage

      public Optional<String> errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • isSuccess

      public boolean isSuccess()
      Returns the value of the isSuccess record component.
      Returns:
      the value of the isSuccess record component
    • errorCode

      public int errorCode()
      Returns the value of the errorCode record component.
      Returns:
      the value of the errorCode record component
    • kafkaErrorCode

      public short kafkaErrorCode()
      Returns the value of the kafkaErrorCode record component.
      Returns:
      the value of the kafkaErrorCode record component
    • isIdempotent

      public boolean isIdempotent()
      Returns the value of the isIdempotent record component.
      Returns:
      the value of the isIdempotent record component
    • keyAssociation

      public Optional<AssociationConfig> keyAssociation()
      Returns the value of the keyAssociation record component.
      Returns:
      the value of the keyAssociation record component
    • valueAssociation

      public Optional<AssociationConfig> valueAssociation()
      Returns the value of the valueAssociation record component.
      Returns:
      the value of the valueAssociation record component