GH-253: Fix NPE in the S3Session
Fixes: https://github.com/spring-projects/spring-integration-aws/issues/253 The `ListObjectsResponse.isTruncated()` is `Boolean`, therefore could be `null` * Fix `S3Session.list(Names)()` to use `Boolean.TRUE.equals()` in `if` instead to have ourselves protected against `NPE`
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,11 +85,11 @@ public class S3Session implements Session<S3Object> {
|
||||
objectListing = this.amazonS3.listObjects(listObjectsRequest.build());
|
||||
List<S3Object> contents = objectListing.contents();
|
||||
objectSummaries.addAll(contents);
|
||||
if (objectListing.isTruncated()) {
|
||||
if (Boolean.TRUE.equals(objectListing.isTruncated())) {
|
||||
listObjectsRequest.marker(contents.get(contents.size() - 1).key());
|
||||
}
|
||||
}
|
||||
while (objectListing.isTruncated());
|
||||
while (Boolean.TRUE.equals(objectListing.isTruncated()));
|
||||
|
||||
return objectSummaries.toArray(new S3Object[0]);
|
||||
}
|
||||
@@ -116,11 +116,11 @@ public class S3Session implements Session<S3Object> {
|
||||
for (S3Object objectSummary : contents) {
|
||||
names.add(objectSummary.key());
|
||||
}
|
||||
if (objectListing.isTruncated()) {
|
||||
if (Boolean.TRUE.equals(objectListing.isTruncated())) {
|
||||
listObjectsRequest.marker(contents.get(contents.size() - 1).key());
|
||||
}
|
||||
}
|
||||
while (objectListing.isTruncated());
|
||||
while (Boolean.TRUE.equals(objectListing.isTruncated()));
|
||||
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user