Oliverwqcwrw commented on code in PR #4687:
URL: https://github.com/apache/rocketmq/pull/4687#discussion_r929697591
##########
namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java:
##########
@@ -62,27 +62,27 @@ public void load() {
public void putKVConfig(final String namespace, final String key, final
String value) {
try {
this.lock.writeLock().lockInterruptibly();
- try {
- HashMap<String, String> kvTable =
this.configTable.get(namespace);
- if (null == kvTable) {
- kvTable = new HashMap<>();
- this.configTable.put(namespace, kvTable);
- log.info("putKVConfig create new Namespace {}", namespace);
- }
+ HashMap<String, String> kvTable = this.configTable.get(namespace);
+ if (null == kvTable) {
+ kvTable = new HashMap<>();
+ this.configTable.put(namespace, kvTable);
+ log.info("putKVConfig create new Namespace {}", namespace);
+ }
- final String prev = kvTable.put(key, value);
- if (null != prev) {
- log.info("putKVConfig update config item, Namespace: {}
Key: {} Value: {}",
- namespace, key, value);
- } else {
- log.info("putKVConfig create new config item, Namespace:
{} Key: {} Value: {}",
- namespace, key, value);
- }
- } finally {
- this.lock.writeLock().unlock();
+ final String prev = kvTable.put(key, value);
+ if (null != prev) {
+ log.info("putKVConfig update config item, Namespace: {} Key:
{} Value: {}",
+ namespace, key, value);
+ } else {
+ log.info("putKVConfig create new config item, Namespace: {}
Key: {} Value: {}",
+ namespace, key, value);
}
} catch (InterruptedException e) {
log.error("putKVConfig InterruptedException", e);
+ // set interrupt flag
+ Thread.currentThread().interrupt();
+ } finally {
+ this.lock.writeLock().unlock();
Review Comment:
Thank you for your reply,
my idea was wrong, I did not think that the lock will throw exception after
the lock failure
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]