From e10b95fb5ed68807745eedbeb31b86911856ba5e Mon Sep 17 00:00:00 2001 From: SSpirits Date: Thu, 4 Jan 2024 10:30:21 +0800 Subject: [PATCH] fix(stream): use getBucketACL instead of headBucket to check if bucket exist (#879) Signed-off-by: SSpirits --- .../java/com/automq/stream/s3/operator/DefaultS3Operator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s3stream/src/main/java/com/automq/stream/s3/operator/DefaultS3Operator.java b/s3stream/src/main/java/com/automq/stream/s3/operator/DefaultS3Operator.java index cb58f8241..e05b2330a 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/operator/DefaultS3Operator.java +++ b/s3stream/src/main/java/com/automq/stream/s3/operator/DefaultS3Operator.java @@ -600,7 +600,7 @@ private void checkAvailable(S3Utils.S3Context s3Context) { String multipartPath = String.format("check_available_multipart/%d", System.nanoTime()); try { // Check network and bucket - readS3Client.headBucket(b -> b.bucket(bucket)).get(3, TimeUnit.SECONDS); + readS3Client.getBucketAcl(b -> b.bucket(bucket)).get(3, TimeUnit.SECONDS); // Simple write/read/delete this.write(path, Unpooled.wrappedBuffer(content)).get(30, TimeUnit.SECONDS); @@ -619,7 +619,7 @@ private void checkAvailable(S3Utils.S3Context s3Context) { LOGGER.error("Failed to write/read/delete object on S3 ", e); String exceptionMsg = String.format("Failed to write/read/delete object on S3. You are using s3Context: %s.", s3Context); - Throwable cause = e.getCause(); + Throwable cause = e.getCause() != null ? e.getCause() : e; if (cause instanceof SdkClientException) { if (cause.getMessage().contains("UnknownHostException")) { Throwable rootCause = ExceptionUtils.getRootCause(cause);