Skip to content

Commit 3cb0ce5

Browse files
authored
build(alert): replace MutableBoolean with AtomicBoolean and remove dependency on Apache's commons-lang3 (#1490)
1 parent f46ee2c commit 3cb0ce5

3 files changed

Lines changed: 23 additions & 23 deletions

File tree

‎pom.xml‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,10 @@
122122
<version>3.6.1</version>
123123
</dependency>
124124

125-
<dependency>
126-
<groupId>org.apache.commons</groupId>
127-
<artifactId>commons-lang3</artifactId>
128-
<version>3.20.0</version>
129-
</dependency>
130-
131125
<dependency>
132126
<groupId>org.apache.commons</groupId>
133127
<artifactId>commons-text</artifactId>
134-
<version>1.15.0</version>
128+
<version>1.15.0</version> <!-- WARNING: if changed, check the `org.apache.commons:commons-lang3` version; see `docs/dependency_conflicts.md` -->
135129
</dependency>
136130

137131
<dependency>
@@ -203,7 +197,7 @@
203197

204198
<dependency>
205199
<groupId>j4ml</groupId>
206-
<artifactId>j4ml-neuroph</artifactId>
200+
<artifactId>j4ml-neuroph</artifactId> <!-- WARNING: if changed, check the `org.apache.commons:commons-lang3` version; see `docs/dependency_conflicts.md` -->
207201
<version>0.9-SNAPSHOT</version>
208202
</dependency>
209203

@@ -281,6 +275,18 @@
281275
<version>0.40</version> <!-- WARNING: if changed, see `docs/dependency_conflicts.md` -->
282276
</dependency>
283277

278+
<!--
279+
resolve convergence conflict of `org.apache.commons:commons-lang3` by choosing the latest used by
280+
- j4ml:j4ml-neuroph:0.9-SNAPSHOT consumes com.github.neuroph:neuroph-core:2.98 which uses version 3.3.2
281+
- org.apache.commons:commons-text:1.15.0 uses version 3.20.0
282+
- see `docs/dependency_conflicts.md` for more info
283+
-->
284+
<dependency>
285+
<groupId>org.apache.commons</groupId>
286+
<artifactId>commons-lang3</artifactId>
287+
<version>3.20.0</version> <!-- WARNING: if changed, see `docs/dependency_conflicts.md` -->
288+
</dependency>
289+
284290
</dependencies>
285291
</dependencyManagement>
286292

‎reconstruction/alert/pom.xml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<groupId>org.apache.commons</groupId>
2323
<artifactId>commons-math3</artifactId>
2424
</dependency>
25-
<dependency>
26-
<groupId>org.apache.commons</groupId>
27-
<artifactId>commons-lang3</artifactId>
28-
<scope>compile</scope>
29-
</dependency>
3025
<dependency>
3126
<groupId>org.jlab.clas</groupId>
3227
<artifactId>clas-reco</artifactId>

‎reconstruction/alert/src/main/java/org/jlab/rec/alert/AI/TrackCandidatesGenerator.java‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.jlab.rec.alert.AI;
22

3-
import org.apache.commons.lang3.mutable.MutableBoolean;
4-
5-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.concurrent.atomic.AtomicBoolean;
66

77
/**
88
* The TrackConstruction class is responsible for constructing all possible track
@@ -81,18 +81,18 @@ private double mod(double x, double y) {
8181
* @param number_of_track_candidates The current count of track candidates.
8282
* @return A list of all possible combinations of integers from {@code v1} and {@code v2}.
8383
*/
84-
private ArrayList<ArrayList<Integer>> cartesianProduct(ArrayList<ArrayList<Integer>> v1, ArrayList<Integer> v2, MutableBoolean too_much_track_candidates, int number_of_track_candidates) {
84+
private ArrayList<ArrayList<Integer>> cartesianProduct(ArrayList<ArrayList<Integer>> v1, ArrayList<Integer> v2, AtomicBoolean too_much_track_candidates, int number_of_track_candidates) {
8585
ArrayList<ArrayList<Integer>> result = new ArrayList<>();
8686
for (ArrayList<Integer> i : v1) {
87-
if (too_much_track_candidates.booleanValue()) break;
87+
if (too_much_track_candidates.get()) break;
8888
for (int j : v2) {
89-
if (too_much_track_candidates.booleanValue()) break;
89+
if (too_much_track_candidates.get()) break;
9090
ArrayList<Integer> n = new ArrayList<>(i);
9191
n.add(j);
9292
result.add(n);
9393

9494
if (number_of_track_candidates + result.size() >= MAX_NUMBER_OF_TRACK_CANDIDATES) {
95-
too_much_track_candidates.setValue(true);
95+
too_much_track_candidates.set(true);
9696
break;
9797
}
9898
}
@@ -155,8 +155,7 @@ else if (interClusters.get(all_superpreclusters.get(i)).getPreclusters().get(0).
155155
superpreclusters_s5.add(all_superpreclusters.get(i));
156156
}
157157

158-
MutableBoolean too_much_track_candidates = new MutableBoolean(); // Need to be a mutable boolean to be able to change it in the cartesian_product method
159-
too_much_track_candidates.setFalse();
158+
AtomicBoolean too_much_track_candidates = new AtomicBoolean(false); // Needs to be mutable so cartesianProduct can set it
160159

161160
// Find all possible combinations of superpreclusters on different superlayers
162161
ArrayList<ArrayList<Integer>> combinations_s1_s2 = cartesianProduct(new ArrayList<>(List.of(superpreclusters_s1)), superpreclusters_s2, too_much_track_candidates, number_of_track_candidates);
@@ -166,7 +165,7 @@ else if (interClusters.get(all_superpreclusters.get(i)).getPreclusters().get(0).
166165

167166
// Keep track of the number of track candidates
168167
number_of_track_candidates += combinations_s1_s2_s3_s4_s5.size();
169-
if (too_much_track_candidates.booleanValue()) sucess = false; // If the number of track candidates exceeds the maximum limit, set success to false
168+
if (too_much_track_candidates.get()) sucess = false; // If the number of track candidates exceeds the maximum limit, set success to false
170169

171170
// Add all track candidates to the list of all track candidates
172171
// And switch back from index to superprecluster

0 commit comments

Comments
 (0)