From 1654e6c79cfbc1ced5a8fa3f726a9f651560be9d Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Mon, 8 Mar 2021 11:27:54 -0500 Subject: [PATCH] AMQ-8169: Synchronize on serviceRead inside NIOSSLTransport This is needed to prevent concurrent access to the SSLEngine during initialization. This is a regression from when auto+nio+ssl was added. --- .../apache/activemq/transport/nio/AutoInitNioSSLTransport.java | 3 ++- .../org/apache/activemq/transport/nio/NIOSSLTransport.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java b/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java index 9301b65644..c0d9df2e10 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java +++ b/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java @@ -158,8 +158,9 @@ public class AutoInitNioSSLTransport extends NIOSSLTransport { return readSize; } + //Prevent concurrent access to SSLEngine @Override - public void serviceRead() { + public synchronized void serviceRead() { try { if (handshakeInProgress) { doHandshake(); diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java b/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java index 9f5e65d9a2..3bcb0e4ec5 100644 --- a/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java +++ b/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java @@ -243,8 +243,9 @@ public class NIOSSLTransport extends NIOTransport { } } + //Prevent concurrent access to SSLEngine @Override - public void serviceRead() { + public synchronized void serviceRead() { try { if (handshakeInProgress) { doHandshake();