From 6d1a83aa485ed9c3644d3200555700070547bf90 Mon Sep 17 00:00:00 2001 From: Jens Geyer Date: Sat, 3 May 2014 00:49:05 +0200 Subject: [PATCH] THRIFT-2506 Update TProtocolException error codes to be used consistently throughout the library Patch: Jens Geyer --- lib/as3/src/org/apache/thrift/protocol/TProtocolError.as | 1 + lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h | 3 ++- lib/csharp/src/Protocol/TProtocolException.cs | 3 ++- lib/d/src/thrift/protocol/base.d | 4 +++- lib/delphi/src/Thrift.Protocol.pas | 3 ++- lib/go/thrift/protocol_exception.go | 1 + lib/hs/src/Thrift/Protocol.hs | 2 ++ .../src/org/apache/thrift/protocol/TProtocolException.java | 1 + lib/lua/TProtocol.lua | 6 +++--- lib/nodejs/lib/thrift/protocol.js | 4 +++- lib/ocaml/src/Thrift.ml | 2 ++ lib/perl/lib/Thrift/Protocol.pm | 3 +++ lib/php/lib/Thrift/Exception/TProtocolException.php | 2 ++ lib/py/src/protocol/TProtocol.py | 2 ++ lib/rb/lib/thrift/protocol/base_protocol.rb | 2 ++ 15 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as b/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as index c5788db0..9fff7308 100644 --- a/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as +++ b/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as @@ -29,6 +29,7 @@ package org.apache.thrift.protocol { public static const SIZE_LIMIT:int = 3; public static const BAD_VERSION:int = 4; public static const NOT_IMPLEMENTED:int = 5; + public static const DEPTH_LIMIT:int = 6; public function TProtocolError(error:int = UNKNOWN, message:String = "") { super(message, error); diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h index df28a4a6..58fe5e0a 100644 --- a/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h +++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h @@ -328,7 +328,8 @@ typedef enum THRIFT_PROTOCOL_ERROR_NEGATIVE_SIZE, THRIFT_PROTOCOL_ERROR_SIZE_LIMIT, THRIFT_PROTOCOL_ERROR_BAD_VERSION, - THRIFT_PROTOCOL_ERROR_NOT_IMPLEMENTED + THRIFT_PROTOCOL_ERROR_NOT_IMPLEMENTED, + THRIFT_PROTOCOL_ERROR_DEPTH_LIMIT } ThriftProtocolError; /* define an error domain for GError to use */ diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs index bc002d3c..05eb2dbd 100644 --- a/lib/csharp/src/Protocol/TProtocolException.cs +++ b/lib/csharp/src/Protocol/TProtocolException.cs @@ -32,7 +32,8 @@ namespace Thrift.Protocol public const int NEGATIVE_SIZE = 2; public const int SIZE_LIMIT = 3; public const int BAD_VERSION = 4; - public const int NOT_IMPLEMENTED= 5; + public const int NOT_IMPLEMENTED = 5; + public const int DEPTH_LIMIT = 6; protected int type_ = UNKNOWN; diff --git a/lib/d/src/thrift/protocol/base.d b/lib/d/src/thrift/protocol/base.d index bd65b711..70648b3c 100644 --- a/lib/d/src/thrift/protocol/base.d +++ b/lib/d/src/thrift/protocol/base.d @@ -207,7 +207,8 @@ class TProtocolException : TException { NEGATIVE_SIZE, /// SIZE_LIMIT, /// BAD_VERSION, /// - NOT_IMPLEMENTED /// + NOT_IMPLEMENTED, /// + DEPTH_LIMIT /// } /// @@ -220,6 +221,7 @@ class TProtocolException : TException { case Type.SIZE_LIMIT: return "Exceeded size limit"; case Type.BAD_VERSION: return "Invalid version"; case Type.NOT_IMPLEMENTED: return "Not implemented"; + case Type.DEPTH_LIMIT: return "Exceeded size limit"; default: return "(Invalid exception type)"; } } diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas index 7ae8e347..4d92cb13 100644 --- a/lib/delphi/src/Thrift.Protocol.pas +++ b/lib/delphi/src/Thrift.Protocol.pas @@ -72,13 +72,14 @@ type TProtocolException = class( Exception ) public - const + const // TODO(jensg): change into enum UNKNOWN : Integer = 0; INVALID_DATA : Integer = 1; NEGATIVE_SIZE : Integer = 2; SIZE_LIMIT : Integer = 3; BAD_VERSION : Integer = 4; NOT_IMPLEMENTED : Integer = 5; + DEPTH_LIMIT : Integer = 6; protected FType : Integer; public diff --git a/lib/go/thrift/protocol_exception.go b/lib/go/thrift/protocol_exception.go index f1a164a8..6e357ee8 100644 --- a/lib/go/thrift/protocol_exception.go +++ b/lib/go/thrift/protocol_exception.go @@ -36,6 +36,7 @@ const ( SIZE_LIMIT = 3 BAD_VERSION = 4 NOT_IMPLEMENTED = 5 + DEPTH_LIMIT = 6 ) type tProtocolException struct { diff --git a/lib/hs/src/Thrift/Protocol.hs b/lib/hs/src/Thrift/Protocol.hs index f3b342a1..6068d165 100644 --- a/lib/hs/src/Thrift/Protocol.hs +++ b/lib/hs/src/Thrift/Protocol.hs @@ -188,6 +188,8 @@ data ProtocolExnType | PE_NEGATIVE_SIZE | PE_SIZE_LIMIT | PE_BAD_VERSION + | PE_NOT_IMPLEMENTED + | PE_DEPTH_LIMIT deriving ( Eq, Show, Typeable ) data ProtocolExn = ProtocolExn ProtocolExnType String diff --git a/lib/java/src/org/apache/thrift/protocol/TProtocolException.java b/lib/java/src/org/apache/thrift/protocol/TProtocolException.java index 248815be..870f1b93 100644 --- a/lib/java/src/org/apache/thrift/protocol/TProtocolException.java +++ b/lib/java/src/org/apache/thrift/protocol/TProtocolException.java @@ -35,6 +35,7 @@ public class TProtocolException extends TException { public static final int SIZE_LIMIT = 3; public static final int BAD_VERSION = 4; public static final int NOT_IMPLEMENTED = 5; + public static final int DEPTH_LIMIT = 6; protected int type_ = UNKNOWN; diff --git a/lib/lua/TProtocol.lua b/lib/lua/TProtocol.lua index 9eb94f59..616e167a 100644 --- a/lib/lua/TProtocol.lua +++ b/lib/lua/TProtocol.lua @@ -26,7 +26,7 @@ TProtocolException = TException:new { SIZE_LIMIT = 3, BAD_VERSION = 4, INVALID_PROTOCOL = 5, - MISSING_REQUIRED_FIELD = 6, + DEPTH_LIMIT = 6, errorCode = 0, __type = 'TProtocolException' } @@ -41,8 +41,8 @@ function TProtocolException:__errorCodeToString() return 'Bad version' elseif self.errorCode == self.INVALID_PROTOCOL then return 'Invalid protocol' - elseif self.errorCode == self.MISSING_REQUIRED_FIELD then - return 'Missing required field' + elseif self.errorCode == self.DEPTH_LIMIT then + return 'Exceeded size limit' else return 'Default (unknown)' end diff --git a/lib/nodejs/lib/thrift/protocol.js b/lib/nodejs/lib/thrift/protocol.js index 5e26ff50..3cf3f410 100644 --- a/lib/nodejs/lib/thrift/protocol.js +++ b/lib/nodejs/lib/thrift/protocol.js @@ -29,7 +29,9 @@ var UNKNOWN = 0, INVALID_DATA = 1, NEGATIVE_SIZE = 2, SIZE_LIMIT = 3, - BAD_VERSION = 4; + BAD_VERSION = 4, + NOT_IMPLEMENTED = 5, + DEPTH_LIMIT = 6; var TProtocolException = function(type, message) { Error.call(this, message); diff --git a/lib/ocaml/src/Thrift.ml b/lib/ocaml/src/Thrift.ml index f176a43b..f0d7a429 100644 --- a/lib/ocaml/src/Thrift.ml +++ b/lib/ocaml/src/Thrift.ml @@ -261,6 +261,8 @@ struct | NEGATIVE_SIZE | SIZE_LIMIT | BAD_VERSION + | NOT_IMPLEMENTED + | DEPTH_LIMIT exception E of exn_type * string;; diff --git a/lib/perl/lib/Thrift/Protocol.pm b/lib/perl/lib/Thrift/Protocol.pm index e2801fee..3e9f0dd1 100644 --- a/lib/perl/lib/Thrift/Protocol.pm +++ b/lib/perl/lib/Thrift/Protocol.pm @@ -34,6 +34,9 @@ use constant INVALID_DATA => 1; use constant NEGATIVE_SIZE => 2; use constant SIZE_LIMIT => 3; use constant BAD_VERSION => 4; +use constant NOT_IMPLEMENTED => 5; +use constant DEPTH_LIMIT => 6; + sub new { my $classname = shift; diff --git a/lib/php/lib/Thrift/Exception/TProtocolException.php b/lib/php/lib/Thrift/Exception/TProtocolException.php index 98a8d9d4..f2529f51 100644 --- a/lib/php/lib/Thrift/Exception/TProtocolException.php +++ b/lib/php/lib/Thrift/Exception/TProtocolException.php @@ -41,6 +41,8 @@ class TProtocolException extends TException { const NEGATIVE_SIZE = 2; const SIZE_LIMIT = 3; const BAD_VERSION = 4; + const NOT_IMPLEMENTED = 5; + const DEPTH_LIMIT = 6; function __construct($message=null, $code=0) { parent::__construct($message, $code); diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py index dc2b095d..40e05b10 100644 --- a/lib/py/src/protocol/TProtocol.py +++ b/lib/py/src/protocol/TProtocol.py @@ -28,6 +28,8 @@ class TProtocolException(TException): NEGATIVE_SIZE = 2 SIZE_LIMIT = 3 BAD_VERSION = 4 + NOT_IMPLEMENTED = 5 + DEPTH_LIMIT = 6 def __init__(self, type=UNKNOWN, message=None): TException.__init__(self, message) diff --git a/lib/rb/lib/thrift/protocol/base_protocol.rb b/lib/rb/lib/thrift/protocol/base_protocol.rb index 2869cc8b..88f44d46 100644 --- a/lib/rb/lib/thrift/protocol/base_protocol.rb +++ b/lib/rb/lib/thrift/protocol/base_protocol.rb @@ -28,6 +28,8 @@ module Thrift NEGATIVE_SIZE = 2 SIZE_LIMIT = 3 BAD_VERSION = 4 + NOT_IMPLEMENTED = 5 + DEPTH_LIMIT = 6 attr_reader :type -- 2.17.1