THRIFT-4024 Skip() should throw on unknown data types
Client: C#, NETCore, Haxe, Delphi, Go
Patch: Jens Geyer
This closes #1155
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 @@
}
prot.ReadListEnd();
break;
+ default:
+ throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d"));
}
}
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 @@
end;
else
- ASSERT( FALSE); // any new types?
+ raise TProtocolExceptionInvalidData.Create('Unexpected type '+IntToStr(Ord(type_)));
end;
end;
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 @@
import (
"errors"
+ "fmt"
)
const (
@@ -170,6 +171,8 @@
}
}
return self.ReadListEnd()
+ default:
+ return NewTProtocolExceptionWithType(INVALID_DATA, errors.New(fmt.Sprintf("Unknown data type %d", fieldType)))
}
return nil
}
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 @@
prot.readListEnd();
default:
- trace("Unknown field type ",type," in skipMaxDepth()");
+ throw new TProtocolException(TProtocolException.UNKNOWN, "Unknown field type ${type}");
}
prot.DecrementRecursionDepth();
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 @@
}
await prot.ReadListEndAsync(cancellationToken);
break;
+ default:
+ throw new TProtocolException(TProtocolException.INVALID_DATA, "Unknown data type " + type.ToString("d"));
}
}
finally