Skip to content

Commit b705ef1

Browse files
Copilotpdurbin
authored andcommitted
Null-check S3 error details in bucket existence helper
1 parent baab128 commit b705ef1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ private static void ensureBucketExists(String bucketName) {
7979
try {
8080
s3localstack.headBucket(HeadBucketRequest.builder().bucket(bucketName).build());
8181
} catch (S3Exception ex) {
82-
if (ex.statusCode() == 404 || "NoSuchBucket".equals(ex.awsErrorDetails().errorCode())) {
82+
String errorCode = ex.awsErrorDetails() == null ? null : ex.awsErrorDetails().errorCode();
83+
if (ex.statusCode() == 404 || "NoSuchBucket".equals(errorCode)) {
8384
s3localstack.createBucket(CreateBucketRequest.builder().bucket(bucketName).build());
8485
} else {
8586
throw ex;

0 commit comments

Comments
 (0)