From 4ef1b09b1b508187fe100c4945f647567d594a4c Mon Sep 17 00:00:00 2001 From: Rocco De Angelis Date: Mon, 25 Sep 2023 14:50:07 +0200 Subject: [PATCH] Make BuildInfoRecorder.java thread safe The buildTimeDependencies collection is a SynchronizedCollection but like mentioned in the JavaDoc of Collections.synchrizedCollection() it is necessary to use a synchronize block by traversing the collection via iterator, what will be happen by hands over the collection to the addAll method. --- .../org/jfrog/buildinfo/deployment/BuildInfoRecorder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jfrog/buildinfo/deployment/BuildInfoRecorder.java b/src/main/java/org/jfrog/buildinfo/deployment/BuildInfoRecorder.java index 6e553e6..09f9acf 100644 --- a/src/main/java/org/jfrog/buildinfo/deployment/BuildInfoRecorder.java +++ b/src/main/java/org/jfrog/buildinfo/deployment/BuildInfoRecorder.java @@ -223,7 +223,9 @@ private void addDependencies(MavenProject project) { // if recordAllDependencies=true, add build time dependencies if (conf.publisher.isRecordAllDependencies()) { - dependencies.addAll(buildTimeDependencies); + synchronized(buildTimeDependencies) { + dependencies.addAll(buildTimeDependencies); + } } currentModuleDependencies.set(dependencies);