You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ju...@apache.org on 2015/11/13 17:29:33 UTC
kafka git commit: KAFKA-2817;
Check if socketChannel is connected in `SslTransportLayer.close`
Repository: kafka
Updated Branches:
refs/heads/trunk 4170847f1 -> 528c78fd3
KAFKA-2817; Check if socketChannel is connected in `SslTransportLayer.close`
This avoids spurious log warning messages. Also tweak log message
if wrapResult.getStatus != CLOSED.
Author: Ismael Juma <is...@juma.me.uk>
Reviewers: Rajini Sivaram <ra...@googlemail.com>, Jun Rao <ju...@gmail.com>
Closes #511 from ijuma/kafka-2817-unconnected-ssl-transport-layer-close
Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/528c78fd
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/528c78fd
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/528c78fd
Branch: refs/heads/trunk
Commit: 528c78fd30b77e8c60e8b3645e7d44404fd4e013
Parents: 4170847
Author: Ismael Juma <is...@juma.me.uk>
Authored: Fri Nov 13 08:29:28 2015 -0800
Committer: Jun Rao <ju...@gmail.com>
Committed: Fri Nov 13 08:29:28 2015 -0800
----------------------------------------------------------------------
.../kafka/common/network/SslTransportLayer.java | 27 +++++++++++---------
1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kafka/blob/528c78fd/clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java b/clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java
index c7873ad..27e2ea9 100644
--- a/clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java
+++ b/clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java
@@ -144,19 +144,22 @@ public class SslTransportLayer implements TransportLayer {
closing = true;
sslEngine.closeOutbound();
try {
- if (!flush(netWriteBuffer)) {
- throw new IOException("Remaining data in the network buffer, can't send SSL close message.");
- }
- //prep the buffer for the close message
- netWriteBuffer.clear();
- //perform the close, since we called sslEngine.closeOutbound
- SSLEngineResult handshake = sslEngine.wrap(emptyBuf, netWriteBuffer);
- //we should be in a close state
- if (handshake.getStatus() != SSLEngineResult.Status.CLOSED) {
- throw new IOException("Invalid close state, will not send network data.");
+ if (isConnected()) {
+ if (!flush(netWriteBuffer)) {
+ throw new IOException("Remaining data in the network buffer, can't send SSL close message.");
+ }
+ //prep the buffer for the close message
+ netWriteBuffer.clear();
+ //perform the close, since we called sslEngine.closeOutbound
+ SSLEngineResult wrapResult = sslEngine.wrap(emptyBuf, netWriteBuffer);
+ //we should be in a close state
+ if (wrapResult.getStatus() != SSLEngineResult.Status.CLOSED) {
+ throw new IOException("Unexpected status returned by SSLEngine.wrap, expected CLOSED, received " +
+ wrapResult.getStatus() + ". Will not send close message to peer.");
+ }
+ netWriteBuffer.flip();
+ flush(netWriteBuffer);
}
- netWriteBuffer.flip();
- flush(netWriteBuffer);
} catch (IOException ie) {
log.warn("Failed to send SSL Close message ", ie);
} finally {