From 75edb29d28b4b852cf8e1edc6b987d4fc68a1cbf Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Mon, 24 Feb 2025 10:49:07 +0100 Subject: [PATCH] Update Javadocs about exception handling when closing composite streams Related to #4764 and #4750 --- .../batch/item/support/CompositeItemReader.java | 6 ++++++ .../batch/item/support/CompositeItemStream.java | 3 ++- .../batch/item/support/CompositeItemWriter.java | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemReader.java index 8da25504f..73a92aa57 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemReader.java @@ -79,6 +79,12 @@ public class CompositeItemReader implements ItemStreamReader { } } + /** + * Close all delegates. + * @throws ItemStreamException thrown if one of the delegates fails to close. Original + * exceptions thrown by delegates are added as suppressed exceptions into this one, in + * the same order as delegates were registered. + */ @Override public void close() throws ItemStreamException { List exceptions = new ArrayList<>(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java index 8cb2a1c83..82f55750e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemStream.java @@ -102,7 +102,8 @@ public class CompositeItemStream implements ItemStream { /** * Broadcast the call to close. * @throws ItemStreamException thrown if one of the {@link ItemStream}s in the list - * fails to close. + * fails to close. Original exceptions thrown by delegates are added as suppressed + * exceptions into this one, in the same order as delegates were registered. */ @Override public void close() throws ItemStreamException { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java index 866611276..730213c96 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemWriter.java @@ -105,6 +105,12 @@ public class CompositeItemWriter implements ItemStreamWriter, Initializing this.delegates = delegates; } + /** + * Close all delegates. + * @throws ItemStreamException thrown if one of the delegates fails to close. Original + * exceptions thrown by delegates are added as suppressed exceptions into this one, in + * the same order as delegates were registered. + */ @Override public void close() throws ItemStreamException { List exceptions = new ArrayList<>();