From 7fdd4876a1e88bb8cd5c81c7c5f1dab814250b30 Mon Sep 17 00:00:00 2001 From: Henning Poettker Date: Sat, 25 Mar 2023 23:56:35 +0100 Subject: [PATCH] Add SafeVarargs annotations --- .../src/main/java/org/springframework/batch/item/Chunk.java | 6 ++++-- .../batch/item/support/CompositeItemWriter.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java index 671743c9ee..084d076041 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java @@ -42,7 +42,7 @@ public class Chunk implements Iterable, Serializable { private List> skips = new ArrayList<>(); - private List errors = new ArrayList<>(); + private final List errors = new ArrayList<>(); private Object userData; @@ -50,10 +50,12 @@ public class Chunk implements Iterable, Serializable { private boolean busy; + @SafeVarargs public Chunk(W... items) { - this(Arrays.stream(items).toList()); + this(Arrays.asList(items)); } + @SafeVarargs public static Chunk of(W... items) { return new Chunk<>(items); } 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 81d8590d8f..d76d5c33e0 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 the original author or authors. + * Copyright 2006-2023 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. @@ -63,6 +63,7 @@ public CompositeItemWriter(List> delegates) { * Convenience constructor for setting the delegates. * @param delegates the array of delegates to use. */ + @SafeVarargs public CompositeItemWriter(ItemWriter... delegates) { this(Arrays.asList(delegates)); }