From 2e623f2c283755ccc87f9f8bd3a1e4f8fdfbfb77 Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Mon, 4 Sep 2023 17:41:23 +0200 Subject: [PATCH] improve exception handling --- source/java/src/org/lucee/extension/resource/s3/S3.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/java/src/org/lucee/extension/resource/s3/S3.java b/source/java/src/org/lucee/extension/resource/s3/S3.java index 44cf0de..dffe817 100755 --- a/source/java/src/org/lucee/extension/resource/s3/S3.java +++ b/source/java/src/org/lucee/extension/resource/s3/S3.java @@ -1252,6 +1252,7 @@ public void copyObject(String srcBucketName, String srcObjectName, String trgBuc srcObjectName = improveObjectName(srcObjectName, false); trgBucketName = improveBucketName(trgBucketName); trgObjectName = improveObjectName(trgObjectName, false); + flushExists(srcBucketName, srcObjectName); flushExists(trgBucketName, trgObjectName); AmazonS3Client client = getAmazonS3(srcBucketName, null); @@ -1292,7 +1293,6 @@ else if (se.getErrorCode().equals("NoSuchBucket") && !client.doesBucketExistV2(t clientTarget.createBucket(cbr); } catch (AmazonS3Exception e) { - // releaseEL(clientTarget); if (customACL) throw e; cbr = new CreateBucketRequest(trgBucketName); clientTarget.createBucket(cbr); @@ -1305,11 +1305,14 @@ else if (se.getErrorCode().equals("NoSuchBucket") && !client.doesBucketExistV2(t clientSource.release(); } } - else throw toS3Exception(se); + else { + throw new S3Exception(se.getErrorCode() + ";could not copy [" + srcBucketName + "/" + srcObjectName + "] to [" + trgBucketName + "/" + trgObjectName + "] ", + se); + } } } catch (AmazonServiceException se) { - throw toS3Exception(se); + throw new S3Exception(se.getErrorCode() + ";could not copy [" + srcBucketName + "/" + srcObjectName + "] to [" + trgBucketName + "/" + trgObjectName + "] ", se); } finally { client.release();