From c8d1dfebab902f4372a924f507b8cc00653ce55c Mon Sep 17 00:00:00 2001 From: dugenkui03 Date: Sat, 16 Apr 2022 21:21:18 +0800 Subject: [PATCH] Make event handling in JobExecutionExitCodeGenerator thread-safe See gh-30705 --- .../autoconfigure/batch/JobExecutionExitCodeGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobExecutionExitCodeGenerator.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobExecutionExitCodeGenerator.java index 28f2d3b141..cd5ce6e511 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobExecutionExitCodeGenerator.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobExecutionExitCodeGenerator.java @@ -16,8 +16,8 @@ package org.springframework.boot.autoconfigure.batch; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import org.springframework.batch.core.JobExecution; import org.springframework.boot.ExitCodeGenerator; @@ -31,7 +31,7 @@ import org.springframework.context.ApplicationListener; */ public class JobExecutionExitCodeGenerator implements ApplicationListener, ExitCodeGenerator { - private final List executions = new ArrayList<>(); + private final List executions = new CopyOnWriteArrayList<>(); @Override public void onApplicationEvent(JobExecutionEvent event) {