Skip to content

Commit f9db4ae

Browse files
committed
GH-253: Fix NPE in the S3Session
Fixes: #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`
1 parent 7776413 commit f9db4ae

File tree

1 file changed

+5
-5
lines changed
  • src/main/java/org/springframework/integration/aws/support

1 file changed

+5
-5
lines changed

src/main/java/org/springframework/integration/aws/support/S3Session.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,11 +85,11 @@ public S3Object[] list(String path) {
8585
objectListing = this.amazonS3.listObjects(listObjectsRequest.build());
8686
List<S3Object> contents = objectListing.contents();
8787
objectSummaries.addAll(contents);
88-
if (objectListing.isTruncated()) {
88+
if (Boolean.TRUE.equals(objectListing.isTruncated())) {
8989
listObjectsRequest.marker(contents.get(contents.size() - 1).key());
9090
}
9191
}
92-
while (objectListing.isTruncated());
92+
while (Boolean.TRUE.equals(objectListing.isTruncated()));
9393

9494
return objectSummaries.toArray(new S3Object[0]);
9595
}
@@ -116,11 +116,11 @@ public String[] listNames(String path) {
116116
for (S3Object objectSummary : contents) {
117117
names.add(objectSummary.key());
118118
}
119-
if (objectListing.isTruncated()) {
119+
if (Boolean.TRUE.equals(objectListing.isTruncated())) {
120120
listObjectsRequest.marker(contents.get(contents.size() - 1).key());
121121
}
122122
}
123-
while (objectListing.isTruncated());
123+
while (Boolean.TRUE.equals(objectListing.isTruncated()));
124124

125125
return names.toArray(new String[0]);
126126
}

0 commit comments

Comments
 (0)