This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 60c2c38b98eb CAMEL-24901: camel-aws2-s3 - document the header-literal
vs configured-Simple key/bucket contract on AWS2S3Utils (#26889)
60c2c38b98eb is described below
commit 60c2c38b98ebbbaf56c10aff491291afe13df474
Author: Andrea Cosentino <[email protected]>
AuthorDate: Mon Sep 28 10:05:42 2026 +0200
CAMEL-24901: camel-aws2-s3 - document the header-literal vs
configured-Simple key/bucket contract on AWS2S3Utils (#26889)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/component/aws2/s3/utils/AWS2S3Utils.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/utils/AWS2S3Utils.java
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/utils/AWS2S3Utils.java
index 638b7e180655..f6cb21e4457b 100644
---
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/utils/AWS2S3Utils.java
+++
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/utils/AWS2S3Utils.java
@@ -41,11 +41,15 @@ public final class AWS2S3Utils {
/**
* Reads the bucket name from the header of the given exchange. If not
provided, it's read from the endpoint
* configuration.
+ * <p>
+ * Only the configured {@code bucketName} may be a dynamic Simple
expression; a bucket name supplied through the
+ * {@code CamelAwsS3OverrideBucketName} header is used literally and is
never evaluated. A configured
+ * {@code bucketName} whose Simple expression resolves to {@code null}
fails fast here.
*
- * @param exchange The exchange to read the header from
+ * @param exchange The exchange to read the bucket name
from
* @param configuration The AWS2 S3 configuration
* @return The bucket name.
- * @throws IllegalArgumentException if the header could not be determined.
+ * @throws IllegalArgumentException if the bucket name is not set or
resolves to {@code null}.
*/
public static String determineBucketName(final Exchange exchange,
AWS2S3Configuration configuration) {
String bucketName =
exchange.getIn().getHeader(AWS2S3Constants.OVERRIDE_BUCKET_NAME, String.class);
@@ -135,6 +139,19 @@ public final class AWS2S3Utils {
}
}
+ /**
+ * Reads the object key from the header of the given exchange. If not
provided, it's read from the endpoint
+ * configuration.
+ * <p>
+ * Only the configured {@code keyName} may be a dynamic Simple expression;
a key supplied through the
+ * {@code CamelAwsS3Key} header is used literally and is never evaluated.
A configured {@code keyName} whose Simple
+ * expression resolves to {@code null} fails fast here instead of passing
a null key to the AWS SDK.
+ *
+ * @param exchange The exchange to read the key from
+ * @param configuration The AWS2 S3 configuration
+ * @return The object key.
+ * @throws IllegalArgumentException if the key is not set or resolves to
{@code null}.
+ */
public static String determineKey(final Exchange exchange,
AWS2S3Configuration configuration) {
String key = exchange.getIn().getHeader(AWS2S3Constants.KEY,
String.class);
if (ObjectHelper.isEmpty(key)) {