You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Mario Kevo (Jira)" <ji...@apache.org> on 2019/12/11 08:10:00 UTC
[jira] [Resolved] (GEODE-6927) possible NPE in
ConnectionTable.getThreadOwnedConnection if concurrent close
[ https://issues.apache.org/jira/browse/GEODE-6927?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mario Kevo resolved GEODE-6927.
-------------------------------
Fix Version/s: 1.12.0
Resolution: Fixed
> possible NPE in ConnectionTable.getThreadOwnedConnection if concurrent close
> ----------------------------------------------------------------------------
>
> Key: GEODE-6927
> URL: https://issues.apache.org/jira/browse/GEODE-6927
> Project: Geode
> Issue Type: Bug
> Components: messaging
> Reporter: Darrel Schneider
> Assignee: Mario Kevo
> Priority: Minor
> Labels: easy-fix, needs-review, pull-request-available
> Fix For: 1.12.0
>
> Time Spent: 2h
> Remaining Estimate: 0h
>
> ConnectionTable.getThreadOwnedConnection has a couple of usages of "this.threadConnectionMap" that could result in an NPE if the ConnectionTable is concurrently closed.
> The unsafe code:
> {code:java}
> if (this.threadConnectionMap == null) {
> // This instance is being destroyed; fail the operation
> closeCon(
> "Connection table being destroyed",
> result);
> return null;
> }
> ArrayList al = (ArrayList) this.threadConnectionMap.get(id);
> if (al == null) {
> // First connection for this DistributedMember. Make sure list for this
> // stub is created if it isn't already there.
> al = new ArrayList();
> // Since it's a concurrent map, we just try to put it and then
> // return whichever we got.
> Object o = this.threadConnectionMap.putIfAbsent(id, al);
> if (o != null) {
> al = (ArrayList) o;
> }
> }
> {code}
> If a close happens after the initial null check but before either the get or putIfAbsent call then a NPE will be thrown.
> All the other code that uses "threadConnectionMap" is careful to save it into a local var, and then use the local var. That is all that is needed here to make this code thread safe.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)