agingade commented on a change in pull request #6613:
URL: https://github.com/apache/geode/pull/6613#discussion_r652250258
##########
File path:
geode-core/src/main/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessage.java
##########
@@ -62,34 +62,34 @@ public int getDSFID() {
@Override
protected void process(ClusterDistributionManager dm) {
- final InternalCache cache = dm.getCache();
- if (cache == null) {
- sendReply(dm, 0);
- return;
- }
- final InternalDistributedRegion region =
- (InternalDistributedRegion) cache.getRegion(this.regionName);
- if (region == null) {
- sendReply(dm, 0);
- return;
- }
- final RegionEntry entry = region.getRegionEntry(this.key);
- if (entry == null) {
- sendReply(dm, 0);
- return;
- }
long lastAccessed = 0L;
- // noinspection SynchronizationOnLocalVariableOrMethodParameter
- synchronized (entry) {
- if (!entry.isInvalidOrRemoved()) {
- try {
- lastAccessed = entry.getLastAccessed();
- } catch (InternalStatisticsDisabledException ignored) {
- // last access time is not available
+ try {
+ final InternalCache cache = dm.getCache();
+ if (cache == null) {
+ return;
+ }
+ final InternalDistributedRegion region =
+ (InternalDistributedRegion) cache.getRegion(this.regionName);
+ if (region == null) {
+ return;
+ }
+ final RegionEntry entry = region.getRegionEntry(this.key);
+ if (entry == null) {
+ return;
+ }
+ // noinspection SynchronizationOnLocalVariableOrMethodParameter
+ synchronized (entry) {
+ if (!entry.isInvalidOrRemoved()) {
+ try {
+ lastAccessed = entry.getLastAccessed();
+ } catch (InternalStatisticsDisabledException ignored) {
+ // last access time is not available
+ }
}
}
+ } finally {
+ sendReply(dm, lastAccessed);
Review comment:
What we want is here to get the last Access time; if the entry is
present and send its value....We could write down the path of checking if its
not null and then access the time. You may have thought about it...And
logically they are all same...I will leave it to you to see which one you want
to pick:
long lastAccessed = 0L;
try {
InternalCache cache = dm.getCache();
if (cache != null) {
InternalDistributedRegion region =
(InternalDistributedRegion) cache.getRegion(regionName);
if (region != null) {
RegionEntry entry = region.getRegionEntry(key);
if (entry != null) {
try {
lastAccessed = entry.getLastAccessed();
} catch (InternalStatisticsDisabledException ignored) {
// last access time is not available
}
}
}
}
} finally {
sendReply(dm, lastAccessed);
}
--
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]