From f9db4ae49335b9a482c6c71249204c440d1a90bf Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 16 Jun 2025 14:26:17 -0400 Subject: [PATCH] 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` --- .../integration/aws/support/S3Session.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/integration/aws/support/S3Session.java b/src/main/java/org/springframework/integration/aws/support/S3Session.java index 95f28e3..73c1509 100644 --- a/src/main/java/org/springframework/integration/aws/support/S3Session.java +++ b/src/main/java/org/springframework/integration/aws/support/S3Session.java @@ -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 { objectListing = this.amazonS3.listObjects(listObjectsRequest.build()); List 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 { 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]); }