Skip to content

NoSuchBucket exception when playing with Path.resolve method #880

Open
@FredPraca

Description

@FredPraca

Bug Description

When using resolve on a S3Path representing a root location, the URI doesn't get changed accordingly.

I use the following code to initialize a Path object to the bucket

rootLocation = s3fs.getPath("/" + bucketName);

Every call received uses a path relative to this root contained in the filePath variable below

Path newPath = s3fs.getPath(dateTimeFormatter.format(LocalDateTime.now()));
// First we create if need the directory for the current time
Path directoryPath = this.rootLocation.resolve(newPath).normalize().toAbsolutePath();

Path destinationFile = directoryPath.resolve(filePath).normalize().toAbsolutePath();

According to toString() method, The directoryPath variable above is formed with something like /bucketname/202502121846/.
But the uri member of the path contains /202502121846 stripping the bucket name.

This leads to a NoSuchBucket exception when trying to write or read the data.

Expected Behavior

The uri should also contain the root directory we are resolving to.

As a note, it was working on the 1.0.6 version but fails on 2.0.0 and 3.0.0.

Environment

  • s3fs-nio version: 3.0.0
  • OS: Linux
  • JDK: 21
  • S3 backend: Minio

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageThe issue needs to be triaged, before work can commence

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions