RongtongJin commented on a change in pull request #723: Concurrent risk in
brokerLiveTable
URL: https://github.com/apache/rocketmq/pull/723#discussion_r396185799
##########
File path:
namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
##########
@@ -422,9 +422,18 @@ public void scanNotActiveBroker() {
long last = next.getValue().getLastUpdateTimestamp();
if ((last + BROKER_CHANNEL_EXPIRED_TIME) <
System.currentTimeMillis()) {
RemotingUtil.closeChannel(next.getValue().getChannel());
- it.remove();
- log.warn("The broker channel expired, {} {}ms", next.getKey(),
BROKER_CHANNEL_EXPIRED_TIME);
- this.onChannelDestroy(next.getKey(),
next.getValue().getChannel());
+ try {
Review comment:
Why not write like this
```java
try {
this.lock.writeLock().lockInterruptibly();
it.remove();
log.warn("The broker channel expired, {} {}ms",
next.getKey(), BROKER_CHANNEL_EXPIRED_TIME);
this.onChannelDestroy(next.getKey(),
next.getValue().getChannel());
} catch (Exception e) {
log.error("Delete Not Active Broker Exception", e);
} finally {
this.lock.writeLock().unlock();
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services