Skip to content

Commit f1cffd1

Browse files
authored
Fix Use fully qualified S3 uris in error message (#4923)
Signed-off-by: Rob Syme <rob.syme@gmail.com>
1 parent 9632366 commit f1cffd1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

plugins/nf-amazon/src/main/nextflow/cloud/aws/nio/S3FileSystemProvider.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public InputStream newInputStream(Path path, OpenOption... options)
202202
S3Path s3Path = (S3Path) path;
203203

204204
Preconditions.checkArgument(!s3Path.getKey().equals(""),
205-
"cannot create InputStream for root directory: %s", s3Path);
205+
"cannot create InputStream for root directory: %s", FilesEx.toUriString(s3Path));
206206

207207
InputStream result;
208208
try {
@@ -213,13 +213,13 @@ public InputStream newInputStream(Path path, OpenOption... options)
213213
.getObjectContent();
214214

215215
if (result == null)
216-
throw new IOException(String.format("The specified path is a directory: %s", path));
216+
throw new IOException(String.format("The specified path is a directory: %s", FilesEx.toUriString(s3Path)));
217217
}
218218
catch (AmazonS3Exception e) {
219219
if (e.getStatusCode() == 404)
220220
throw new NoSuchFileException(path.toString());
221221
// otherwise throws a generic IO exception
222-
throw new IOException(String.format("Cannot access file: %s", path),e);
222+
throw new IOException(String.format("Cannot access file: %s", FilesEx.toUriString(s3Path)),e);
223223
}
224224

225225
return result;
@@ -258,11 +258,11 @@ public OutputStream newOutputStream(final Path path, final OpenOption... options
258258
if (!(create && truncateExisting)) {
259259
if (exists(s3Path)) {
260260
if (createNew || !truncateExisting) {
261-
throw new FileAlreadyExistsException(path.toString());
261+
throw new FileAlreadyExistsException(FilesEx.toUriString(s3Path));
262262
}
263263
} else {
264264
if (!createNew && !create) {
265-
throw new NoSuchFileException(path.toString());
265+
throw new NoSuchFileException(FilesEx.toUriString(s3Path));
266266
}
267267
}
268268
}
@@ -496,13 +496,13 @@ public void delete(Path path) throws IOException {
496496
S3Path s3Path = (S3Path) path;
497497

498498
if (Files.notExists(path)){
499-
throw new NoSuchFileException("the path: " + path + " does not exist");
499+
throw new NoSuchFileException("the path: " + FilesEx.toUriString(s3Path) + " does not exist");
500500
}
501501

502502
if (Files.isDirectory(path)){
503503
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)){
504504
if (stream.iterator().hasNext()){
505-
throw new DirectoryNotEmptyException("the path: " + path + " is a directory and is not empty");
505+
throw new DirectoryNotEmptyException("the path: " + FilesEx.toUriString(s3Path) + " is a directory and is not empty");
506506
}
507507
}
508508
}
@@ -541,7 +541,7 @@ public void copy(Path source, Path target, CopyOption... options)
541541
if (!actualOptions.contains(StandardCopyOption.REPLACE_EXISTING)) {
542542
if (exists(s3Target)) {
543543
throw new FileAlreadyExistsException(format(
544-
"target already exists: %s", target));
544+
"target already exists: %s", FilesEx.toUriString(s3Target)));
545545
}
546546
}
547547

0 commit comments

Comments
 (0)