You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2022/08/24 15:55:16 UTC
[qpid-proton-j] branch main updated: PROTON-2347: Fix leakage of socket handles when soketChannel.connect() fails with an Exception (socketChannel.close() is not called.)
This is an automated email from the ASF dual-hosted git repository.
robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton-j.git
The following commit(s) were added to refs/heads/main by this push:
new 70717726 PROTON-2347: Fix leakage of socket handles when soketChannel.connect() fails with an Exception (socketChannel.close() is not called.)
70717726 is described below
commit 7071772619d8bc596b30b01cc7816118abc9e598
Author: Einar Bergseth <ei...@e2usystems.com>
AuthorDate: Thu Aug 20 13:56:48 2020 +0200
PROTON-2347: Fix leakage of socket handles when soketChannel.connect() fails with an Exception (socketChannel.close() is not called.)
This closes #38
---
.../java/org/apache/qpid/proton/reactor/impl/IOHandler.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
index 5d58182d..e95384b5 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
@@ -158,12 +158,20 @@ public class IOHandler extends BaseHandler {
Transport transport = event.getConnection().getTransport();
Socket socket = null; // In this case, 'null' is the proton-j equivalent of PN_INVALID_SOCKET
+ SocketChannel socketChannel = null;
try {
- SocketChannel socketChannel = ((ReactorImpl)reactor).getIO().socketChannel();
+ socketChannel = ((ReactorImpl)reactor).getIO().socketChannel();
socketChannel.configureBlocking(false);
socketChannel.connect(new InetSocketAddress(hostname, port));
socket = socketChannel.socket();
} catch(Exception exception) {
+ if (socketChannel != null) {
+ try {
+ socketChannel.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
ErrorCondition condition = new ErrorCondition();
condition.setCondition(Symbol.getSymbol("proton:io"));
condition.setDescription(exception.getMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org