From aeaad006cd926f7c6742c270da1ce96f4d3228df Mon Sep 17 00:00:00 2001 From: dugenkui03 Date: Sat, 16 Apr 2022 21:21:18 +0800 Subject: [PATCH] Make event handling in ClassPathFileSystemWatcherTests thread-safe See gh-30844 --- .../devtools/classpath/ClassPathFileSystemWatcherTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileSystemWatcherTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileSystemWatcherTests.java index 1bd8ba26faa..146f542e966 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileSystemWatcherTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/classpath/ClassPathFileSystemWatcherTests.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -116,7 +117,7 @@ class ClassPathFileSystemWatcherTests { static class Listener implements ApplicationListener { - private List events = new ArrayList<>(); + private List events = new CopyOnWriteArrayList<>(); @Override public void onApplicationEvent(ClassPathChangedEvent event) {