You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/12/04 17:09:37 UTC
git commit: https://issues.apache.org/jira/browse/AMQ-4889
Updated Branches:
refs/heads/trunk 3a8ee8115 -> 69e35d6c4
https://issues.apache.org/jira/browse/AMQ-4889
Improve the stream close logic in the init method to ensure we don't
leak and resources.
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/69e35d6c
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/69e35d6c
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/69e35d6c
Branch: refs/heads/trunk
Commit: 69e35d6c4a77c1c693587dd84b9032118fa7b7bd
Parents: 3a8ee81
Author: Timothy Bish <ta...@gmai.com>
Authored: Wed Dec 4 11:09:28 2013 -0500
Committer: Timothy Bish <ta...@gmai.com>
Committed: Wed Dec 4 11:09:28 2013 -0500
----------------------------------------------------------------------
.../activemq/transport/nio/NIOSSLTransport.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/69e35d6c/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java
----------------------------------------------------------------------
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 52c3e97..02789f3 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
@@ -34,7 +34,6 @@ import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
-import org.apache.activemq.command.Command;
import org.apache.activemq.command.ConnectionInfo;
import org.apache.activemq.openwire.OpenWireFormat;
import org.apache.activemq.thread.TaskRunnerFactory;
@@ -75,6 +74,7 @@ public class NIOSSLTransport extends NIOTransport {
@Override
protected void initializeStreams() throws IOException {
+ NIOOutputStream outputStream = null;
try {
channel = socket.getChannel();
channel.configureBlocking(false);
@@ -119,7 +119,7 @@ public class NIOSSLTransport extends NIOTransport {
inputBuffer = ByteBuffer.allocate(sslSession.getPacketBufferSize());
inputBuffer.clear();
- NIOOutputStream outputStream = new NIOOutputStream(channel);
+ outputStream = new NIOOutputStream(channel);
outputStream.setEngine(sslEngine);
this.dataOut = new DataOutputStream(outputStream);
this.buffOut = outputStream;
@@ -127,6 +127,12 @@ public class NIOSSLTransport extends NIOTransport {
handshakeStatus = sslEngine.getHandshakeStatus();
doHandshake();
} catch (Exception e) {
+ try {
+ if(outputStream != null) {
+ outputStream.close();
+ }
+ super.closeStreams();
+ } catch (Exception ex) {}
throw new IOException(e);
}
}
@@ -143,10 +149,12 @@ public class NIOSSLTransport extends NIOTransport {
// listen for events telling us when the socket is readable.
selection = SelectorManager.getInstance().register(channel, new SelectorManager.Listener() {
+ @Override
public void onSelect(SelectorSelection selection) {
serviceRead();
}
+ @Override
public void onError(SelectorSelection selection, Throwable error) {
if (error instanceof IOException) {
onException((IOException) error);
@@ -158,6 +166,7 @@ public class NIOSSLTransport extends NIOTransport {
}
}
+ @Override
protected void serviceRead() {
try {
if (handshakeInProgress) {
@@ -272,7 +281,7 @@ public class NIOSSLTransport extends NIOTransport {
} else {
currentBuffer.flip();
Object command = wireFormat.unmarshal(new DataInputStream(new NIOInputStream(currentBuffer)));
- doConsume((Command) command);
+ doConsume(command);
nextFrameSize = -1;
currentBuffer = null;
}