This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 845003f Fix semaphore usage error when calculating address. (#7850)
845003f is described below
commit 845003f500fa3bb0ac3f1bf41ee4d55b71720fa8
Author: panxiaojun233 <[email protected]>
AuthorDate: Mon May 24 11:54:12 2021 +0800
Fix semaphore usage error when calculating address. (#7850)
* fix addr cache bug
* fix router chain loop err
---
.../main/java/org/apache/dubbo/rpc/cluster/RouterChain.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
index 29a7be5..a895677 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
@@ -267,11 +267,11 @@ public class RouterChain<T> {
}
if (notify) {
if (loopPermitNotify.tryAcquire()) {
- loopPool.submit(new NotifyLoopRunnable(true));
+ loopPool.submit(new NotifyLoopRunnable(true,
loopPermitNotify));
}
} else {
if (loopPermit.tryAcquire()) {
- loopPool.submit(new NotifyLoopRunnable(false));
+ loopPool.submit(new NotifyLoopRunnable(false, loopPermit));
}
}
}
@@ -279,14 +279,16 @@ public class RouterChain<T> {
class NotifyLoopRunnable implements Runnable {
private final boolean notify;
+ private final Semaphore loopPermit;
- public NotifyLoopRunnable(boolean notify) {
+ public NotifyLoopRunnable(boolean notify, Semaphore loopPermit) {
this.notify = notify;
+ this.loopPermit = loopPermit;
}
@Override
public void run() {
- loopPermitNotify.release();
+ loopPermit.release();
buildCache(notify);
}
}