This is an automated email from the ASF dual-hosted git repository.
dmollitor 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 47e9d8f THRIFT-5197: TSSLTransportFactory Do Not Wrap NOT_OPEN
Exception Type for Client Client: java Patch: David Mollitor
47e9d8f is described below
commit 47e9d8f13e5194e0f69cea3942c00b8e3ea6be9f
Author: David Mollitor <[email protected]>
AuthorDate: Mon May 11 10:26:37 2020 -0400
THRIFT-5197: TSSLTransportFactory Do Not Wrap NOT_OPEN Exception Type for
Client
Client: java
Patch: David Mollitor
This closes #2131
The class TSSLTransportFactory is wrapping TTransportExceptions, which have
a particular "type,"
in a type-less TTransportException and therefore the Exception type is lost.
---
.../src/org/apache/thrift/transport/TSSLTransportFactory.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/java/src/org/apache/thrift/transport/TSSLTransportFactory.java
b/lib/java/src/org/apache/thrift/transport/TSSLTransportFactory.java
index 73dfaaf..570f533 100644
--- a/lib/java/src/org/apache/thrift/transport/TSSLTransportFactory.java
+++ b/lib/java/src/org/apache/thrift/transport/TSSLTransportFactory.java
@@ -172,7 +172,7 @@ public class TSSLTransportFactory {
*/
public static TSocket getClientSocket(String host, int port, int timeout,
TSSLTransportParameters params) throws TTransportException {
if (params == null || !(params.isKeyStoreSet || params.isTrustStoreSet)) {
- throw new TTransportException("Either one of the KeyStore or TrustStore
must be set for SSLTransportParameters");
+ throw new TTransportException(TTransportException.NOT_OPEN, "Either one
of the KeyStore or TrustStore must be set for SSLTransportParameters");
}
SSLContext ctx = createSSLContext(params);
@@ -225,7 +225,7 @@ public class TSSLTransportFactory {
}
} catch (Exception e) {
- throw new TTransportException("Error creating the transport", e);
+ throw new TTransportException(TTransportException.NOT_OPEN, "Error
creating the transport", e);
} finally {
if (in != null) {
try {
@@ -275,8 +275,10 @@ public class TSSLTransportFactory {
SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
socket.setSoTimeout(timeout);
return new TSocket(socket);
+ } catch (TTransportException tte) {
+ throw tte;
} catch (Exception e) {
- throw new TTransportException("Could not connect to " + host + " on port
" + port, e);
+ throw new TTransportException(TTransportException.NOT_OPEN, "Could not
connect to " + host + " on port " + port, e);
}
}