You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2017/01/11 19:51:26 UTC

thrift git commit: THRIFT-4024 Skip() should throw on unknown data types Client: C#, NETCore, Haxe, Delphi, Go Patch: Jens Geyer

Repository: thrift
Updated Branches:
  refs/heads/master 4f710aa4f -> 5f723cd53


THRIFT-4024 Skip() should throw on unknown data types
Client: C#, NETCore, Haxe, Delphi, Go
Patch: Jens Geyer

This closes #1155


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/5f723cd5
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/5f723cd5
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/5f723cd5

Branch: refs/heads/master
Commit: 5f723cd53980f395a92c438790a127cbd5699d90
Parents: 4f710aa
Author: Jens Geyer <je...@apache.org>
Authored: Tue Jan 10 21:57:48 2017 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Wed Jan 11 20:50:38 2017 +0100

----------------------------------------------------------------------
 lib/csharp/src/Protocol/TProtocolUtil.cs                 | 2 ++
 lib/delphi/src/Thrift.Protocol.pas                       | 2 +-
 lib/go/thrift/protocol.go                                | 3 +++
 lib/haxe/src/org/apache/thrift/protocol/TProtocolUtil.hx | 2 +-
 lib/netcore/Thrift/Protocols/Utilities/TProtocolUtil.cs  | 2 ++
 5 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/5f723cd5/lib/csharp/src/Protocol/TProtocolUtil.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Protocol/TProtocolUtil.cs b/lib/csharp/src/Protocol/TProtocolUtil.cs
index 0932a7f..0606c71 100644
--- a/lib/csharp/src/Protocol/TProtocolUtil.cs
+++ b/lib/csharp/src/Protocol/TProtocolUtil.cs
@@ -95,6 +95,8 @@ namespace Thrift.Protocol
                         }
                         prot.ReadListEnd();
                         break;
+                    default:
+                        throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d"));
                 }
 
             }

http://git-wip-us.apache.org/repos/asf/thrift/blob/5f723cd5/lib/delphi/src/Thrift.Protocol.pas
----------------------------------------------------------------------
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas
index 7ff2eae..9ea28de 100644
--- a/lib/delphi/src/Thrift.Protocol.pas
+++ b/lib/delphi/src/Thrift.Protocol.pas
@@ -823,7 +823,7 @@ begin
     end;
 
   else
-    ASSERT( FALSE); // any new types?
+    raise TProtocolExceptionInvalidData.Create('Unexpected type '+IntToStr(Ord(type_)));
   end;
 end;
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/5f723cd5/lib/go/thrift/protocol.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/protocol.go b/lib/go/thrift/protocol.go
index 45fa202..32bb7b3 100644
--- a/lib/go/thrift/protocol.go
+++ b/lib/go/thrift/protocol.go
@@ -21,6 +21,7 @@ package thrift
 
 import (
 	"errors"
+	"fmt"
 )
 
 const (
@@ -170,6 +171,8 @@ func Skip(self TProtocol, fieldType TType, maxDepth int) (err error) {
 			}
 		}
 		return self.ReadListEnd()
+	default:
+		return NewTProtocolExceptionWithType(INVALID_DATA, errors.New(fmt.Sprintf("Unknown data type %d", fieldType)))
 	}
 	return nil
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/5f723cd5/lib/haxe/src/org/apache/thrift/protocol/TProtocolUtil.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolUtil.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolUtil.hx
index 1ec59d2..001e405 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TProtocolUtil.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocolUtil.hx
@@ -95,7 +95,7 @@ class TProtocolUtil {
                     prot.readListEnd();
 
                 default:
-                    trace("Unknown field type ",type," in skipMaxDepth()");
+					throw new TProtocolException(TProtocolException.UNKNOWN, "Unknown field type ${type}");
             }
 
             prot.DecrementRecursionDepth();

http://git-wip-us.apache.org/repos/asf/thrift/blob/5f723cd5/lib/netcore/Thrift/Protocols/Utilities/TProtocolUtil.cs
----------------------------------------------------------------------
diff --git a/lib/netcore/Thrift/Protocols/Utilities/TProtocolUtil.cs b/lib/netcore/Thrift/Protocols/Utilities/TProtocolUtil.cs
index 6232149..038edb9 100644
--- a/lib/netcore/Thrift/Protocols/Utilities/TProtocolUtil.cs
+++ b/lib/netcore/Thrift/Protocols/Utilities/TProtocolUtil.cs
@@ -97,6 +97,8 @@ namespace Thrift.Protocols
                         }
                         await prot.ReadListEndAsync(cancellationToken);
                         break;
+                    default:
+                        throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d"));
                 }
             }
             finally