[
https://issues.jboss.org/browse/JGRP-2271?page=com.atlassian.jira.plugin....
]
Bela Ban edited comment on JGRP-2271 at 6/15/18 3:59 AM:
---------------------------------------------------------
Hmm, this is a bit more complicated than I thought: {{Socket.isConnected()}} returns true
if is has been connected, even if it has been closed later! So the correct condition
should be {{if(sock.isConnected() && !sock.isClosed())}} !
This is bad as {{Socket.isClosed()}} acquires {{sockLock}}, which is costly. I guess
keeping a {{connected}} variable in {{Connection}} itself, which is set to true on
successful connect and false on close, is our best option...
was (Author: belaban):
Hmm, this is a bit more complicated than I thought: Socket.isConnected() returns true if
is has been connected, even if it has been closed later! So the correct condition should
be {{if(sock.isConnected() && !sock.isClosed())}} !
This is bad as Socket.isClosed() acquired {{sockLock}}, which is costly. I guess keeping a
{{connected}} variable in {{Connection}} itself, which is set to true on successful
connect and false on close, is our best option...
Race condition in BaseServer.getConnection
------------------------------------------
Key: JGRP-2271
URL:
https://issues.jboss.org/browse/JGRP-2271
Project: JGroups
Issue Type: Bug
Affects Versions: 3.6.10
Reporter: Dennis Reed
Assignee: Bela Ban
Fix For: 4.0.12, 3.6.16
BaseServer.getConnection creates a socket and puts it in the shared map under a lock.
However it does not connect the socket inside the lock, so another thread calling
getConnection at the same time can get the unconnected socket, which will throw a NPE when
used because it's not connected yet (all the checks before returning and using it only
look for isOpen, not isConnected).
java.lang.NullPointerException
at org.jgroups.blocks.cs.TcpConnection.doSend(TcpConnection.java:184)
at org.jgroups.blocks.cs.TcpConnection._send(TcpConnection.java:171)
at org.jgroups.blocks.cs.TcpConnection.send(TcpConnection.java:141)
at org.jgroups.blocks.cs.BaseServer.send(BaseServer.java:185)
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)