THRIFT-738. java: TCompactProtocol throws RuntimeException when it can't identify a type identifier
This patch causes it to throw TProtocolException instead.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@924364 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java b/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java
index ea333b6..8c29b3c 100755
--- a/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java
+++ b/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java
@@ -20,11 +20,11 @@
package org.apache.thrift.protocol;
-import java.util.Stack;
import java.io.UnsupportedEncodingException;
+import java.util.Stack;
-import org.apache.thrift.transport.TTransport;
import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransport;
/**
* TCompactProtocol2 is the Java implementation of the compact protocol specified
@@ -729,7 +729,7 @@
* Given a TCompactProtocol.Types constant, convert it to its corresponding
* TType value.
*/
- private byte getTType(byte type) {
+ private byte getTType(byte type) throws TProtocolException {
switch ((byte)(type & 0x0f)) {
case TType.STOP:
return TType.STOP;
@@ -757,7 +757,7 @@
case Types.STRUCT:
return TType.STRUCT;
default:
- throw new RuntimeException("don't know what type: " + (byte)(type & 0x0f));
+ throw new TProtocolException("don't know what type: " + (byte)(type & 0x0f));
}
}