THRIFT-4779: fix exception type in TMultiplexedProcessor
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 @@
      *         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 @@
         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 @@
                 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 @@
     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):