Record Class SSEParserConfig

java.lang.Object
java.lang.Record
org.a2aproject.sdk.client.http.SSEParserConfig
Record Components:
maxLineLength - max bytes per raw SSE line (0 = disabled)
maxBufferLines - max data: lines per event block
maxBufferChars - max total characters across all data: values per event

public record SSEParserConfig(int maxLineLength, int maxBufferLines, int maxBufferChars) extends Record
Configuration for ServerSentEventParser limits.

All limits have safe defaults suitable for most deployments. Use the SSEParserConfig.Builder to override individual values -- for example, to raise the per-event character budget for agents that return large artifacts.

Enforcement semantics: maxLineLength is enforced at the transport layer as a byte limit on raw UTF-8 data, before lines are decoded to characters. For ASCII-only content (the common case for SSE/JSON-RPC), bytes and characters are equivalent. For multi-byte UTF-8 content, the byte-level check is stricter — a line of maxLineLength multi-byte characters may exceed the limit. This is intentional: the byte-level enforcement prevents memory exhaustion from a malicious unterminated line before it is fully materialised.

Security note: setting maxLineLength to 0 disables the per-line memory protection entirely. Without this limit, a malicious server sending a single unterminated line (no newline) can consume unbounded memory — maxBufferChars only limits accumulated data: field values after lines have been decoded, not the raw line itself. Only disable the per-line check when you trust the remote agent or have other safeguards (e.g. a reverse proxy that enforces its own line-length limit).

  • Field Details

    • DEFAULT

      public static final SSEParserConfig DEFAULT
      Default configuration: 1 MB per-line and per-event character limit, 1 000 data lines per event.
  • Constructor Details

    • SSEParserConfig

      public SSEParserConfig(int maxLineLength, int maxBufferLines, int maxBufferChars)
      Creates an instance of a SSEParserConfig record class.
      Parameters:
      maxLineLength - the value for the maxLineLength record component
      maxBufferLines - the value for the maxBufferLines record component
      maxBufferChars - the value for the maxBufferChars record component
  • Method Details

    • builder

      public static SSEParserConfig.Builder builder()
      Returns a new SSEParserConfig.Builder initialized with the DEFAULT values.
    • 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. All components in this record class 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.
    • maxLineLength

      public int maxLineLength()
      Returns the value of the maxLineLength record component.
      Returns:
      the value of the maxLineLength record component
    • maxBufferLines

      public int maxBufferLines()
      Returns the value of the maxBufferLines record component.
      Returns:
      the value of the maxBufferLines record component
    • maxBufferChars

      public int maxBufferChars()
      Returns the value of the maxBufferChars record component.
      Returns:
      the value of the maxBufferChars record component