Skip to content

Commit 925fa97

Browse files
committed
Deprecate constructor with unused parameters
1 parent 96b825a commit 925fa97

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,20 @@ public class FileAttributes
6767

6868
private final FileTime lastModifiedTime;
6969

70+
/**
71+
* @deprecated use {@link #FileAttributes(File)} and remove the unused userCache and groupCache parameters
72+
*/
73+
@Deprecated
7074
public FileAttributes( @Nonnull File file, @Nonnull Map<Integer, String> userCache,
7175
@Nonnull Map<Integer, String> groupCache )
7276
throws IOException
7377
{
78+
this( file );
79+
}
80+
81+
public FileAttributes( @Nonnull File file )
82+
throws IOException
83+
{
7484

7585
Path path = file.toPath();
7686
Set<String> views = path.getFileSystem().supportedFileAttributeViews();
@@ -130,7 +140,7 @@ public FileAttributes( @Nullable Integer userId, String userName, @Nullable Inte
130140
PlexusIoResourceAttributes uncached( @Nonnull File file )
131141
throws IOException
132142
{
133-
return new FileAttributes( file, new HashMap<Integer, String>(), new HashMap<Integer, String>() );
143+
return new FileAttributes( file );
134144
}
135145

136146
@Nullable

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.File;
2323
import java.io.IOException;
2424
import java.util.Collections;
25-
import java.util.HashMap;
2625
import java.util.LinkedHashMap;
2726
import java.util.List;
2827
import java.util.Map;
@@ -160,7 +159,6 @@ public static boolean isOctalModeEnabled( int mode, int targetMode )
160159
return ( mode & targetMode ) != 0;
161160
}
162161

163-
@SuppressWarnings( { "UnusedDeclaration" } )
164162
public static PlexusIoResourceAttributes getFileAttributes( File file )
165163
throws IOException
166164
{
@@ -186,8 +184,6 @@ Map<String, PlexusIoResourceAttributes> getFileAttributesByPath( @Nonnull File d
186184
boolean recursive )
187185
throws IOException
188186
{
189-
Map<Integer, String> userCache = new HashMap<>();
190-
Map<Integer, String> groupCache = new HashMap<>();
191187
final List<String> fileAndDirectoryNames;
192188
if ( recursive && dir.isDirectory() )
193189
{
@@ -202,8 +198,7 @@ Map<String, PlexusIoResourceAttributes> getFileAttributesByPath( @Nonnull File d
202198

203199
for ( String fileAndDirectoryName : fileAndDirectoryNames )
204200
{
205-
attributesByPath.put( fileAndDirectoryName,
206-
new FileAttributes( new File( fileAndDirectoryName ), userCache, groupCache ) );
201+
attributesByPath.put( fileAndDirectoryName, new FileAttributes( new File( fileAndDirectoryName ) ) );
207202
}
208203
return attributesByPath;
209204
}

src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoFileResourceCollection.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,12 @@ private void addResources( List<PlexusIoResource> result, String[] resources )
152152
{
153153

154154
final File dir = getBaseDir();
155-
final HashMap<Integer, String> cache1 = new HashMap<>();
156-
final HashMap<Integer, String> cache2 = new HashMap<>();
157155
for ( String name : resources )
158156
{
159157
String sourceDir = name.replace( '\\', '/' );
160158
File f = new File( dir, sourceDir );
161159

162-
FileAttributes fattrs = new FileAttributes( f, cache1, cache2 );
160+
FileAttributes fattrs = new FileAttributes( f );
163161
PlexusIoResourceAttributes attrs = mergeAttributes( fattrs, fattrs.isDirectory() );
164162

165163
String remappedName = getName( name );

src/test/java/org/codehaus/plexus/components/io/attributes/AttributeUtilsTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ public void testChmodBackAndForth()
5454
return;
5555
final File bxx = File.createTempFile( "bxx", "ff" );
5656
AttributeUtils.chmod( bxx, 0422 );
57-
PlexusIoResourceAttributes firstAttrs =
58-
new FileAttributes( bxx, new HashMap<Integer, String>(), new HashMap<Integer, String>() );
57+
PlexusIoResourceAttributes firstAttrs = new FileAttributes( bxx );
5958
assertTrue( firstAttrs.isOwnerReadable() );
6059
assertFalse( firstAttrs.isOwnerWritable() );
6160
assertFalse( firstAttrs.isOwnerExecutable() );
6261
AttributeUtils.chmod( bxx, 0777 );
63-
PlexusIoResourceAttributes secondAttrs =
64-
new FileAttributes( bxx, new HashMap<Integer, String>(), new HashMap<Integer, String>() );
62+
PlexusIoResourceAttributes secondAttrs = new FileAttributes( bxx );
6563
assertTrue( secondAttrs.isOwnerReadable() );
6664
assertTrue( secondAttrs.isOwnerWritable() );
6765
assertTrue( secondAttrs.isOwnerExecutable() );

src/test/java/org/codehaus/plexus/components/io/attributes/FileAttributesTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ public void testGetPosixFileAttributes()
3939
}
4040

4141
File file = new File( "." );
42-
Map<Integer, String> userCache = new HashMap<>();
43-
Map<Integer, String> groupCache = new HashMap<>();
4442

45-
PlexusIoResourceAttributes fa = new FileAttributes( file, userCache, groupCache );
43+
PlexusIoResourceAttributes fa = new FileAttributes( file );
4644
assertNotNull( fa );
4745
}
4846

0 commit comments

Comments
 (0)