THRIFT-3345 Clients blocked indefinitely when a java.lang.Error is thrown
Client: Java
Author: huahang <huahang@users.noreply.github.com>
This closes #618
diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
index a963bc9..0529d72 100755
--- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
+++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
@@ -295,22 +295,19 @@
LOGGER.error("Thrift error occurred during processing of message.", tx);
} catch (Exception x) {
LOGGER.error("Error occurred during processing of message.", x);
- }
-
- if (eventHandler != null) {
- eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
- }
-
- if (inputTransport != null) {
- inputTransport.close();
- }
-
- if (outputTransport != null) {
- outputTransport.close();
- }
-
- if (client_.isOpen()) {
- client_.close();
+ } finally {
+ if (eventHandler != null) {
+ eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
+ }
+ if (inputTransport != null) {
+ inputTransport.close();
+ }
+ if (outputTransport != null) {
+ outputTransport.close();
+ }
+ if (client_.isOpen()) {
+ client_.close();
+ }
}
}
}