Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In CacheItem, it's better to use the private and final keywords to modify the member variable rwLock. #10964

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class CacheItem {
*/
private volatile Map<String, ConfigCache> configCacheTags = null;

public SimpleReadWriteLock rwLock = new SimpleReadWriteLock();
private final SimpleReadWriteLock rwLock = new SimpleReadWriteLock();

public CacheItem(String groupKey, String encryptedDataKey) {
this.groupKey = StringPool.get(groupKey);
Expand Down Expand Up @@ -104,10 +104,6 @@ public SimpleReadWriteLock getRwLock() {
return rwLock;
}

public void setRwLock(SimpleReadWriteLock rwLock) {
this.rwLock = rwLock;
}

public String getType() {
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ public static boolean isUptodate(String groupKey, String md5, String ip, String
*/
public static int tryReadLock(String groupKey) {
CacheItem groupItem = CACHE.get(groupKey);
int result = (null == groupItem) ? 0 : (groupItem.rwLock.tryReadLock() ? 1 : -1);
int result = (null == groupItem) ? 0 : (groupItem.getRwLock().tryReadLock() ? 1 : -1);
if (result < 0) {
DEFAULT_LOG.warn("[read-lock] failed, {}, {}", result, groupKey);
}
Expand All @@ -846,7 +846,7 @@ public static int tryReadLock(String groupKey) {
public static void releaseReadLock(String groupKey) {
CacheItem item = CACHE.get(groupKey);
if (null != item) {
item.rwLock.releaseReadLock();
item.getRwLock().releaseReadLock();
}
}

Expand All @@ -859,7 +859,7 @@ public static void releaseReadLock(String groupKey) {
*/
static int tryWriteLock(String groupKey) {
CacheItem groupItem = CACHE.get(groupKey);
int result = (null == groupItem) ? 0 : (groupItem.rwLock.tryWriteLock() ? 1 : -1);
int result = (null == groupItem) ? 0 : (groupItem.getRwLock().tryWriteLock() ? 1 : -1);
if (result < 0) {
DEFAULT_LOG.warn("[write-lock] failed, {}, {}", result, groupKey);
}
Expand All @@ -869,7 +869,7 @@ static int tryWriteLock(String groupKey) {
static void releaseWriteLock(String groupKey) {
CacheItem groupItem = CACHE.get(groupKey);
if (null != groupItem) {
groupItem.rwLock.releaseWriteLock();
groupItem.getRwLock().releaseWriteLock();
}
}

Expand Down
Loading