You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2019/02/08 05:34:08 UTC

[thrift] branch master updated: THRIFT-4779: fix exception type in TMultiplexedProcessor

This is an automated email from the ASF dual-hosted git repository.

jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 74a3e09  THRIFT-4779: fix exception type in TMultiplexedProcessor
74a3e09 is described below

commit 74a3e0923d9425fd0c3c854b770782148f91ec19
Author: James E. King III <jk...@apache.org>
AuthorDate: Thu Feb 7 19:33:52 2019 -0500

    THRIFT-4779: fix exception type in TMultiplexedProcessor
---
 .../src/org/apache/thrift/TMultiplexedProcessor.java | 15 +++++++++------
 lib/py/src/TMultiplexedProcessor.py                  | 20 +++++++++++++++-----
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java b/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java
index 14b541d..c494862 100644
--- a/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java
+++ b/lib/java/src/org/apache/thrift/TMultiplexedProcessor.java
@@ -87,7 +87,7 @@ public class TMultiplexedProcessor implements TProcessor {
      *         that allows readMessageBegin() to return the original TMessage.</li>
      * </ol>
      *
-     * @throws TException If the message type is not CALL or ONEWAY, if
+     * @throws TProtocolException If the message type is not CALL or ONEWAY, if
      * the service name was not found in the message, or if the service
      * name was not found in the service map.  You called {@link #registerProcessor(String, TProcessor) registerProcessor}
      * during initialization, right? :)
@@ -101,7 +101,8 @@ public class TMultiplexedProcessor implements TProcessor {
         TMessage message = iprot.readMessageBegin();
 
         if (message.type != TMessageType.CALL && message.type != TMessageType.ONEWAY) {
-            throw new TException("This should not have happened!?");
+            throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
+                "This should not have happened!?");
         }
 
         // Extract the service name
@@ -112,16 +113,18 @@ public class TMultiplexedProcessor implements TProcessor {
                 defaultProcessor.process(new StoredMessageProtocol(iprot, message), oprot);
                 return;
           }
-            throw new TException("Service name not found in message name: " + message.name + ".  Did you " +
-                    "forget to use a TMultiplexProtocol in your client?");
+            throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
+                "Service name not found in message name: " + message.name + ".  Did you " +
+                "forget to use a TMultiplexProtocol in your client?");
         }
 
         // Create a new TMessage, something that can be consumed by any TProtocol
         String serviceName = message.name.substring(0, index);
         TProcessor actualProcessor = SERVICE_PROCESSOR_MAP.get(serviceName);
         if (actualProcessor == null) {
-            throw new TException("Service name not found: " + serviceName + ".  Did you forget " +
-                    "to call registerProcessor()?");
+            throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED,
+                "Service name not found: " + serviceName + ".  Did you forget " +
+                "to call registerProcessor()?");
         }
 
         // Create a new TMessage, removing the service name
diff --git a/lib/py/src/TMultiplexedProcessor.py b/lib/py/src/TMultiplexedProcessor.py
index 3ac5af0..8d929ac 100644
--- a/lib/py/src/TMultiplexedProcessor.py
+++ b/lib/py/src/TMultiplexedProcessor.py
@@ -17,8 +17,9 @@
 # under the License.
 #
 
-from thrift.Thrift import TProcessor, TMessageType, TException
+from thrift.Thrift import TProcessor, TMessageType
 from thrift.protocol import TProtocolDecorator, TMultiplexedProtocol
+from thrift.protocol.TProtocol import TProtocolException
 
 
 class TMultiplexedProcessor(TProcessor):
@@ -31,19 +32,28 @@ class TMultiplexedProcessor(TProcessor):
     def process(self, iprot, oprot):
         (name, type, seqid) = iprot.readMessageBegin()
         if type != TMessageType.CALL and type != TMessageType.ONEWAY:
-            raise TException("TMultiplexed protocol only supports CALL & ONEWAY")
+            raise TProtocolException(
+                TProtocolException.NOT_IMPLEMENTED,
+                "TMultiplexedProtocol only supports CALL & ONEWAY")
 
         index = name.find(TMultiplexedProtocol.SEPARATOR)
         if index < 0:
-            raise TException("Service name not found in message name: " + name + ". Did you forget to use TMultiplexedProtocol in your client?")
+            raise TProtocolException(
+                TProtocolException.NOT_IMPLEMENTED,
+                "Service name not found in message name: " + name + ".  " +
+                "Did you forget to use TMultiplexedProtocol in your client?")
 
         serviceName = name[0:index]
         call = name[index + len(TMultiplexedProtocol.SEPARATOR):]
         if serviceName not in self.services:
-            raise TException("Service name not found: " + serviceName + ". Did you forget to call registerProcessor()?")
+            raise TProtocolException(
+                TProtocolException.NOT_IMPLEMENTED,
+                "Service name not found: " + serviceName + ".  " +
+                "Did you forget to call registerProcessor()?")
 
         standardMessage = (call, type, seqid)
-        return self.services[serviceName].process(StoredMessageProtocol(iprot, standardMessage), oprot)
+        return self.services[serviceName].process(
+            StoredMessageProtocol(iprot, standardMessage), oprot)
 
 
 class StoredMessageProtocol(TProtocolDecorator.TProtocolDecorator):