From 60b3c033f9ec5c793f7f8af75f1b58b5a4997af2 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Fri, 15 May 2026 10:52:54 +0200 Subject: [PATCH] THRIFT-6006: Implement MESSAGE_SIZE_LIMIT exception type for Haxe library Client: haxe - Add CORRUPTED_DATA = 5 and MESSAGE_SIZE_LIMIT = 6 to TTransportException - Replace END_OF_FILE throws with MESSAGE_SIZE_LIMIT in TEndpointTransport for ResetConsumedMessageSize, CheckReadBytesAvailable, CountConsumedMessageBytes - Improve error messages to include the configured limit and actual byte counts Co-Authored-By: Claude Sonnet 4.6 --- .../src/org/apache/thrift/transport/TEndpointTransport.hx | 6 +++--- .../src/org/apache/thrift/transport/TTransportException.hx | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/haxe/src/org/apache/thrift/transport/TEndpointTransport.hx b/lib/haxe/src/org/apache/thrift/transport/TEndpointTransport.hx index fad3b549245..f1b9777a005 100644 --- a/lib/haxe/src/org/apache/thrift/transport/TEndpointTransport.hx +++ b/lib/haxe/src/org/apache/thrift/transport/TEndpointTransport.hx @@ -60,7 +60,7 @@ class TEndpointTransport extends TTransport // update only: message size can shrink, but not grow if (newSize > KnownMessageSize) - throw new TTransportException(TTransportException.END_OF_FILE, "ResetConsumedMessageSize: MaxMessageSize reached"); + throw new TTransportException(TTransportException.MESSAGE_SIZE_LIMIT, 'ResetConsumedMessageSize: message size exceeds limit ${MaxMessageSize}'); KnownMessageSize = newSize; RemainingMessageSize = newSize; @@ -79,7 +79,7 @@ class TEndpointTransport extends TTransport public override function CheckReadBytesAvailable(numBytes : Int64) : Void { if (RemainingMessageSize < numBytes || numBytes < 0) - throw new TTransportException(TTransportException.END_OF_FILE, 'CheckReadBytesAvailable(${numBytes}): MaxMessageSize reached, only ${RemainingMessageSize} bytes available'); + throw new TTransportException(TTransportException.MESSAGE_SIZE_LIMIT, 'CheckReadBytesAvailable(${numBytes}): message size exceeds limit ${MaxMessageSize}, only ${RemainingMessageSize} bytes available'); } // Consumes numBytes from the RemainingMessageSize. @@ -92,7 +92,7 @@ class TEndpointTransport extends TTransport else { RemainingMessageSize = 0; - throw new TTransportException(TTransportException.END_OF_FILE, 'CountConsumedMessageBytes(${numBytes}): MaxMessageSize reached'); + throw new TTransportException(TTransportException.MESSAGE_SIZE_LIMIT, 'CountConsumedMessageBytes(${numBytes}): message size exceeds limit ${MaxMessageSize}'); } } } diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx index ad028dd8639..c623c7fb50b 100644 --- a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx +++ b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx @@ -30,6 +30,8 @@ class TTransportException extends TException { public static inline var ALREADY_OPEN : Int = 2; public static inline var TIMED_OUT : Int = 3; public static inline var END_OF_FILE : Int = 4; + public static inline var CORRUPTED_DATA : Int = 5; + public static inline var MESSAGE_SIZE_LIMIT : Int = 6; public function new(error : Int = UNKNOWN, message : String = "") { super(message, error);