Skip to content

Commit 9d4c410

Browse files
authored
Avoid unnecessary ssl error log caused by jdk bug (apache#16709)
1 parent 3ec8979 commit 9d4c410

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/NettyTNonblockingTransport.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ protected void initChannel(SocketChannel ch) throws Exception {
168168
"SSL handshake completed successfully for {}:{}", host, port);
169169
}
170170
} else {
171-
if (!future
172-
.cause()
173-
.getMessage()
174-
.contains("SslHandler removed before handshake completed")) {
171+
if (future.cause().getMessage() != null
172+
&& !future
173+
.cause()
174+
.getMessage()
175+
.contains("SslHandler removed before handshake completed")) {
175176
logger.warn(
176177
"SSL handshake failed for {}:{}", host, port, future.cause());
177178
} else if (logger.isDebugEnabled()) {

iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TElasticFramedTransport.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,21 @@ public int read(byte[] buf, int off, int len) throws TTransportException {
132132
if (e.getCause() instanceof SocketTimeoutException) {
133133
throw new TTransportException(TTransportException.TIMED_OUT, e.getCause());
134134
}
135-
// When client with SSL shut down due to time out. Some unnecessary error logs may be printed.
136-
// Adding this workaround to avoid the problem.
137-
if (e.getCause() instanceof SSLHandshakeException
138-
&& e.getCause().getCause() != null
139-
&& e.getCause().getCause() instanceof EOFException) {
140-
throw new TTransportException(TTransportException.END_OF_FILE, e.getCause());
135+
if (e.getCause() instanceof SSLHandshakeException) {
136+
// There is an unsolved JDK bug https://bugs.openjdk.org/browse/JDK-8221218.
137+
// Adding this workaround to avoid the error log printed.
138+
if (e.getMessage()
139+
.contains("Insufficient buffer remaining for AEAD cipher fragment (2).")) {
140+
throw new TTransportException(TTransportException.END_OF_FILE, e.getCause());
141+
}
142+
// When client with SSL shutdown due to time out. Some unnecessary error logs may be
143+
// printed.
144+
// Adding this workaround to avoid the problem.
145+
if (e.getCause().getCause() != null && e.getCause().getCause() instanceof EOFException) {
146+
throw new TTransportException(TTransportException.END_OF_FILE, e.getCause());
147+
}
141148
}
149+
142150
if (e.getCause() instanceof SSLException
143151
&& e.getMessage().contains("Unsupported or unrecognized SSL message")) {
144152
SocketAddress remoteAddress = null;

0 commit comments

Comments
 (0)