Skip to content

Commit

Permalink
S3Path: Make 'uri' and 'fileSystem' final.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Hekman authored and steve-todorov committed Jul 26, 2023
1 parent db43415 commit ba86f91
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/main/java/org/carlspring/cloud/storage/s3fs/S3Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public class S3Path
* URI not encoded
* Is the key for S3Client
*/
private String uri;
private final String uri;

/**
* actual filesystem
*/
private S3FileSystem fileSystem;
private final S3FileSystem fileSystem;

/**
* S3BasicFileAttributes cache
Expand Down Expand Up @@ -109,18 +109,16 @@ public S3Path(S3FileSystem fileSystem, String first, String... more)
uriBuilder.append(path + PATH_SEPARATOR);
}
}

this.uri = normalizeURI(uriBuilder.toString());
String localUri = normalizeURI(uriBuilder.toString());
// remove last PATH_SEPARATOR
if (!first.isEmpty() &&
// only first param and not ended with PATH_SEPARATOR
((!first.endsWith(PATH_SEPARATOR) && (more == null || more.length == 0))
// we have more param and not ended with PATH_SEPARATOR
|| more != null && more.length > 0 && !more[more.length - 1].endsWith(PATH_SEPARATOR)))
{
this.uri = this.uri.substring(0, this.uri.length() - 1);
// only first param and not ended with PATH_SEPARATOR
((!first.endsWith(PATH_SEPARATOR) && (more == null || more.length == 0))
// we have more param and not ended with PATH_SEPARATOR
|| more != null && more.length > 0 && !more[more.length-1].endsWith(PATH_SEPARATOR))) {
localUri = localUri.substring(0, localUri.length() - 1);
}

this.uri = localUri;
this.fileSystem = fileSystem;
}

Expand Down

0 comments on commit ba86f91

Please sign in to comment.