Skip to content

Commit 839e2d0

Browse files
committed
Fetch group and owner name only when not present in cache.
Improves performance on systems which has high time penalty when fetching owner and group name.
1 parent 76768c1 commit 839e2d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/codehaus/plexus/components/io/attributes/FileAttributes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCac
7676
}
7777
else
7878
{
79-
Map<String, Object> groupAttrs = Files.readAttributes( path, "unix:group", LinkOption.NOFOLLOW_LINKS);
80-
this.groupName = ( (Principal) groupAttrs.get( "group" ) ).getName();
79+
Object group = Files.getAttribute( path, "unix:group", LinkOption.NOFOLLOW_LINKS );
80+
this.groupName = ( (Principal) group ).getName();
8181
groupCache.put( groupId, this.groupName );
8282
}
8383
userId = (Integer) attrs.get( "uid" );
@@ -88,8 +88,8 @@ public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCac
8888
}
8989
else
9090
{
91-
Map<String, Object> ownerAttrs = Files.readAttributes( path, "unix:owner", LinkOption.NOFOLLOW_LINKS);
92-
this.userName = ( (Principal) ownerAttrs.get( "owner" )).getName();
91+
Object owner = Files.getAttribute( path, "unix:owner", LinkOption.NOFOLLOW_LINKS );
92+
this.userName = ( (Principal) owner ).getName();
9393
userCache.put( userId, this.userName );
9494
}
9595
octalMode = (Integer) attrs.get( "mode" ) & 0xfff; // Mask off top bits for compatibilty. Maybe check if we

0 commit comments

Comments
 (0)