[ROCKETMQ-261] Use write lock when destroy IndexService
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/332df78e Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/332df78e Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/332df78e Branch: refs/heads/master Commit: 332df78e2bb6caadfc6f4714450000ebb1f9d224 Parents: f613c3b Author: yukon <yu...@apache.org> Authored: Fri Aug 11 22:17:32 2017 +0800 Committer: yukon <yu...@apache.org> Committed: Fri Aug 11 22:17:32 2017 +0800 ---------------------------------------------------------------------- .../main/java/org/apache/rocketmq/store/index/IndexService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/332df78e/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java ---------------------------------------------------------------------- diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java index e562c2a..b565349 100644 --- a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java +++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java @@ -142,7 +142,7 @@ public class IndexService { public void destroy() { try { - this.readWriteLock.readLock().lock(); + this.readWriteLock.writeLock().lock(); for (IndexFile f : this.indexFileList) { f.destroy(1000 * 3); } @@ -150,7 +150,7 @@ public class IndexService { } catch (Exception e) { log.error("destroy exception", e); } finally { - this.readWriteLock.readLock().unlock(); + this.readWriteLock.writeLock().unlock(); } }