Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
Expand Down Expand Up @@ -207,7 +206,7 @@ private List<Resource> findResourcesInBucketWithKeyPattern(String s3BucketName,
return s3ObjectKeyMatchesS3KeyPattern;
}).peek(s3Object -> LOGGER.debug("Resolved key: {} based on pattern: {}", s3Object.key(), s3KeyPattern))
.map(s3Object -> getResource(S3_PROTOCOL_PREFIX + s3BucketName + "/" + s3Object.key()))
.collect(Collectors.toList());
.toList();
}

/**
Expand Down Expand Up @@ -259,7 +258,7 @@ private List<String> findMatchingBuckets(String bucketPattern) {
bucketNameMatchesBucketPattern);
return bucketNameMatchesBucketPattern;
}).peek(name -> LOGGER.debug("Resolved bucket name: {} based on pattern: {}", name, bucketPattern))
.collect(Collectors.toList());
.toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.integration.file.remote.AbstractFileInfo;
import org.springframework.integration.file.remote.AbstractRemoteFileStreamingMessageSource;
import org.springframework.integration.file.remote.RemoteFileTemplate;
Expand Down Expand Up @@ -47,7 +46,7 @@ public S3StreamingMessageSource(RemoteFileTemplate<S3Object> template, Comparato

@Override
protected List<AbstractFileInfo<S3Object>> asFileInfoList(Collection<S3Object> collection) {
return collection.stream().map(S3FileInfo::new).collect(Collectors.toList());
return collection.stream().map(S3FileInfo::new).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -81,7 +80,7 @@ public void start() {
synchronized (this.lifecycleMonitor) {
logger.debug("Starting {}", getClass().getSimpleName());
List<MessageListenerContainer<?>> containersToStart = this.listenerContainers.values().stream()
.filter(SmartLifecycle::isAutoStartup).collect(Collectors.toList());
.filter(SmartLifecycle::isAutoStartup).toList();
LifecycleHandler.get().start(containersToStart);
this.running = true;
logger.debug("{} started", getClass().getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
import org.springframework.messaging.Message;

/**
Expand All @@ -43,7 +42,7 @@ public InterceptorExecutionFailedException(String message, Throwable cause, Mess
public <T> InterceptorExecutionFailedException(String message, Throwable cause,
Collection<Message<T>> failedMessages) {
super(message, cause);
this.failedMessages = failedMessages.stream().map(msg -> (Message<?>) msg).collect(Collectors.toList());
this.failedMessages = failedMessages.stream().map(msg -> (Message<?>) msg).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
import org.jspecify.annotations.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
Expand All @@ -41,7 +40,7 @@ public ListenerExecutionFailedException(String message, Throwable cause, Message
public <T> ListenerExecutionFailedException(String message, Throwable cause,
Collection<Message<T>> failedMessages) {
super(message, cause);
this.failedMessages = failedMessages.stream().map(msg -> (Message<?>) msg).collect(Collectors.toList());
this.failedMessages = failedMessages.stream().map(msg -> (Message<?>) msg).toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,12 @@ private <T> CompletableFuture<SendResult.Batch<T>> wrapSendException(Collection<

private <T> CompletableFuture<SendResult.Batch<T>> handleFailedSendBatch(String endpoint,
SendResult.Batch<T> result) {
return CompletableFuture.failedFuture(new SendBatchOperationFailedException("", endpoint, result));
String errorMessage = "Send batch operation failed for endpoint %s. Failed messages: %s.".formatted(endpoint,
result.failed().stream()
.map(failed -> "[Message ID: %s, Error: %s]"
.formatted(MessageHeaderUtils.getRawMessageId(failed.message()), failed.errorMessage()))
.collect(Collectors.joining(", ")));
return CompletableFuture.failedFuture(new SendBatchOperationFailedException(errorMessage, endpoint, result));
}

private <T> Collection<S> convertMessagesToSend(Collection<Message<T>> messages) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.mockito.Mockito.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.awspring.cloud.sqs.MessageHeaderUtils;
import io.awspring.cloud.sqs.QueueAttributesResolvingException;
import io.awspring.cloud.sqs.SqsAcknowledgementException;
import io.awspring.cloud.sqs.listener.QueueNotFoundStrategy;
Expand Down Expand Up @@ -555,6 +556,8 @@ void shouldThrowIfHasFailedMessagesInBatchByDefault() {
assertThatThrownBy(() -> template.sendMany(queue, messages))
.isInstanceOf(SendBatchOperationFailedException.class)
.isInstanceOfSatisfying(SendBatchOperationFailedException.class, ex -> {
assertThat(ex.getMessage()).contains(queue).contains(testErrorMessage)
.contains(MessageHeaderUtils.getRawMessageId(message2));
assertThat(ex.getFailedMessages().iterator().next().getPayload()).isEqualTo(payload2);
assertThat(ex.getEndpoint()).isEqualTo(queue);
SendResult.Batch<String> sendBatchResult = ex.getSendBatchResult(String.class);
Expand Down