Skip to content

Commit

Permalink
fix #6444 NPE (#6793)
Browse files Browse the repository at this point in the history
* fix #6444 NPE

* agin ci

* del DubboProtocol#getSharedClient locks.remove(key)
  • Loading branch information
manzhizhen committed Oct 13, 2020
1 parent f9f10ba commit 8d06e5e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public static DubboProtocol getDubboProtocol() {
return INSTANCE;
}

@Override
public Collection<Exporter<?>> getExporters() {
return Collections.unmodifiableCollection(exporterMap.values());
}
Expand Down Expand Up @@ -458,7 +459,7 @@ private List<ReferenceCountExchangeClient> getSharedClient(URL url, int connectN
locks.putIfAbsent(key, new Object());
synchronized (locks.get(key)) {
clients = referenceClientMap.get(key);
// dubbo check
// double check
if (checkClientCanUse(clients)) {
batchClientRefIncr(clients);
return clients;
Expand Down Expand Up @@ -488,8 +489,10 @@ private List<ReferenceCountExchangeClient> getSharedClient(URL url, int connectN
/*
* I understand that the purpose of the remove operation here is to avoid the expired url key
* always occupying this memory space.
* But "locks.remove(key);" can lead to "synchronized (locks.get(key)) {" NPE, considering that the key of locks is "IP + port",
* it will not lead to the expansion of "locks" in theory, so I will annotate it here.
*/
locks.remove(key);
// locks.remove(key);

return clients;
}
Expand Down

0 comments on commit 8d06e5e

Please sign in to comment.