@@ -98,8 +98,6 @@ public class S3FileSystemProvider extends FileSystemProvider {
98
98
static final String SCHEME = "s3" ;
99
99
private static final Map <String , S3FileSystem > FS_CACHE = new ConcurrentHashMap <>();
100
100
101
- protected S3NioSpiConfiguration configuration = new S3NioSpiConfiguration ();
102
-
103
101
private final Logger logger = LoggerFactory .getLogger (this .getClass ().getName ());
104
102
105
103
/**
@@ -384,11 +382,12 @@ public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOExcept
384
382
directoryKey = directoryKey + PATH_SEPARATOR ;
385
383
}
386
384
387
- var timeOut = configuration .getTimeoutLow ();
385
+ var s3FileSystem = s3Directory .getFileSystem ();
386
+ var timeOut = s3FileSystem .configuration ().getTimeoutLow ();
388
387
final var unit = MINUTES ;
389
388
390
389
try {
391
- s3Directory . getFileSystem () .client ().putObject (
390
+ s3FileSystem .client ().putObject (
392
391
PutObjectRequest .builder ()
393
392
.bucket (s3Directory .bucketName ())
394
393
.key (directoryKey )
@@ -417,9 +416,10 @@ public void delete(Path path) throws IOException {
417
416
final var prefix = s3Path .toRealPath (NOFOLLOW_LINKS ).getKey ();
418
417
final var bucketName = s3Path .bucketName ();
419
418
420
- final var s3Client = s3Path .getFileSystem ().client ();
419
+ final var s3FileSystem = s3Path .getFileSystem ();
420
+ final var s3Client = s3FileSystem .client ();
421
421
422
- var timeOut = configuration .getTimeoutLow ();
422
+ var timeOut = s3FileSystem . configuration () .getTimeoutLow ();
423
423
final var unit = MINUTES ;
424
424
try {
425
425
var keys = s3Path .isDirectory () ?
@@ -470,10 +470,11 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
470
470
var s3SourcePath = checkPath (source );
471
471
var s3TargetPath = checkPath (target );
472
472
473
- final var s3Client = s3SourcePath .getFileSystem ().client ();
473
+ final var s3FileSystem = s3SourcePath .getFileSystem ();
474
+ final var s3Client = s3FileSystem .client ();
474
475
final var sourceBucket = s3SourcePath .bucketName ();
475
476
476
- final var timeOut = configuration .getTimeoutHigh ();
477
+ final var timeOut = s3FileSystem . configuration () .getTimeoutHigh ();
477
478
final var unit = MINUTES ;
478
479
479
480
var fileExistsAndCannotReplace = cannotReplaceAndFileExistsCheck (options , s3Client );
@@ -645,7 +646,7 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
645
646
final var s3Path = checkPath (path .toRealPath (NOFOLLOW_LINKS ));
646
647
final var response = getCompletableFutureForHead (s3Path );
647
648
648
- var timeOut = configuration .getTimeoutLow ();
649
+ var timeOut = s3Path . getFileSystem (). configuration () .getTimeoutLow ();
649
650
var unit = MINUTES ;
650
651
651
652
try {
@@ -749,8 +750,9 @@ public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type
749
750
var s3Path = checkPath (path );
750
751
751
752
if (type .equals (BasicFileAttributes .class )) {
753
+ var timeoutLow = s3Path .getFileSystem ().configuration ().getTimeoutLow ();
752
754
@ SuppressWarnings ("unchecked" )
753
- var a = (A ) S3BasicFileAttributes .get (s3Path , Duration .ofMinutes (configuration . getTimeoutLow () ));
755
+ var a = (A ) S3BasicFileAttributes .get (s3Path , Duration .ofMinutes (timeoutLow ));
754
756
return a ;
755
757
} else {
756
758
throw new UnsupportedOperationException ("cannot read attributes of type: " + type );
@@ -786,8 +788,9 @@ public Map<String, Object> readAttributes(Path path, String attributes, LinkOpti
786
788
return Collections .emptyMap ();
787
789
}
788
790
791
+ var timeoutLow = s3Path .getFileSystem ().configuration ().getTimeoutLow ();
789
792
var attributesFilter = attributesFilterFor (attributes );
790
- return S3BasicFileAttributes .get (s3Path , Duration .ofMinutes (configuration . getTimeoutLow () )).asMap (attributesFilter );
793
+ return S3BasicFileAttributes .get (s3Path , Duration .ofMinutes (timeoutLow )).asMap (attributesFilter );
791
794
}
792
795
793
796
/**
@@ -801,15 +804,6 @@ public void setAttribute(Path path, String attribute, Object value, LinkOption..
801
804
throw new UnsupportedOperationException ("s3 file attributes cannot be modified by this class" );
802
805
}
803
806
804
- /**
805
- * Set custom configuration. This configuration is referred to for API timeouts
806
- *
807
- * @param configuration The new configuration containing the timeout info
808
- */
809
- public void setConfiguration (S3NioSpiConfiguration configuration ) {
810
- this .configuration = configuration ;
811
- }
812
-
813
807
/**
814
808
* @param path the path of the file to open or create
815
809
* @param options options specifying how the file is opened
@@ -881,8 +875,9 @@ private void closeFileSystemIfOpen(FileSystem fs) throws IOException {
881
875
882
876
boolean exists (S3AsyncClient s3Client , S3Path path ) throws InterruptedException , TimeoutException {
883
877
try {
878
+ var timeoutLow = path .getFileSystem ().configuration ().getTimeoutLow ();
884
879
s3Client .headObject (HeadObjectRequest .builder ().bucket (path .bucketName ()).key (path .getKey ()).build ())
885
- .get (configuration . getTimeoutLow () , MINUTES );
880
+ .get (timeoutLow , MINUTES );
886
881
return true ;
887
882
} catch (ExecutionException | NoSuchKeyException e ) {
888
883
logger .debug ("Could not retrieve object head information" , e );
0 commit comments