THRIFT-3769 : Fix logic of THRIFT-2268
Client: java
diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
index 53c20e9..3b5f21e 100644
--- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
+++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
@@ -311,14 +311,24 @@
break;
}
}
- } catch (TSaslTransportException ttx) {
- // Something thats not SASL was in the stream, continue silently
- } catch (TTransportException ttx) {
- // Assume the client died and continue silently
} catch (TException tx) {
LOGGER.error("Thrift error occurred during processing of message.", tx);
} catch (Exception x) {
- LOGGER.error("Error occurred during processing of message.", x);
+ // We'll usually receive RuntimeException types here
+ // Need to unwrap to ascertain real causing exception before we choose to ignore
+ Throwable realCause = x.getCause();
+ // Ignore err-logging all transport-level/type exceptions
+ if ((realCause != null && realCause instanceof TTransportException)
+ || (x instanceof TTransportException)) {
+ if (LOGGER.isDebugEnabled()) {
+ // Write to debug, just in case the exception gets required
+ LOGGER
+ .debug("Received TTransportException during processing of message, ignoring: ", x);
+ }
+ } else {
+ // Log the exception at error level and continue
+ LOGGER.error("Error occurred during processing of message.", x);
+ }
} finally {
if (eventHandler != null) {
eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);