You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2021/07/01 14:38:08 UTC

[GitHub] [jackrabbit-oak] jelmini commented on a change in pull request #309: OAK-9467 added utility object to wrap the segment file and last modif…

jelmini commented on a change in pull request #309:
URL: https://github.com/apache/jackrabbit-oak/pull/309#discussion_r662348748



##########
File path: oak-segment-remote/src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentDiskCache.java
##########
@@ -193,16 +188,27 @@ public void cleanUp() {
     private void cleanUpInternal() {
         if (isCacheFull()) {
             try {
-                Stream<Path> segmentsPaths = Files.walk(directory.toPath())
+                Stream<SegmentCacheEntry> segmentCacheEntryStream = Files.walk(directory.toPath())
+                        .map(path -> {
+                            try {
+                                return new SegmentCacheEntry(path, Files.readAttributes(path, BasicFileAttributes.class).lastAccessTime());
+                            } catch (IOException e) {
+                                logger.error("Error while getting the last access time for {}", path.toFile().getName());
+                            }
+                            return new SegmentCacheEntry(null, FileTime.fromMillis(Long.MAX_VALUE));

Review comment:
       Minor: as a matter of style, I think it's better to move the last return inside the catch clause because it makes clear that there is an happy path result and an error path result.
   ```suggestion
                               } catch (IOException e) {
                                   logger.error("Error while getting the last access time for {}", path.toFile().getName());
                                   return new SegmentCacheEntry(null, FileTime.fromMillis(Long.MAX_VALUE));
                               }
   ```




-- 
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: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org