This is an automated email from the ASF dual-hosted git repository.
denes pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 38a1f47 NIFI-9055 Added handling for 0- read range to FetchS3Object
(#5317)
38a1f47 is described below
commit 38a1f476e3ecf425d7fd333e04c262d009bf2c96
Author: Joey <[email protected]>
AuthorDate: Mon Sep 13 10:19:19 2021 -0700
NIFI-9055 Added handling for 0- read range to FetchS3Object (#5317)
---
.../org/apache/nifi/processors/aws/s3/FetchS3Object.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git
a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java
b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java
index 2d6a446..719f1cf 100644
---
a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java
+++
b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java
@@ -171,9 +171,23 @@ public class FetchS3Object extends AbstractS3Processor {
request = new GetObjectRequest(bucket, key, versionId);
}
request.setRequesterPays(requesterPays);
+
+ // tl;dr don't setRange(0) on GetObjectRequest because it results in
+ // InvalidRange errors on zero byte objects.
+ //
+ // Amazon S3 sets byte ranges using HTTP Range headers as described in
+ // https://datatracker.ietf.org/doc/html/rfc2616#section-14.35 and
+ // https://datatracker.ietf.org/doc/html/rfc7233#section-2.1. There
+ // isn't a satisfiable byte range specification for zero length objects
+ // so 416 (Request range not satisfiable) is returned.
+ //
+ // Since the effect of the byte range 0- is equivalent to not sending a
+ // byte range and works for both zero and non-zero length objects,
+ // the single argument setRange() only needs to be called when the
+ // first byte position is greater than zero.
if (rangeLength != null) {
request.setRange(rangeStart, rangeStart + rangeLength - 1);
- } else {
+ } else if (rangeStart > 0) {
request.setRange(rangeStart);
}