Skip to content

Commit 07f06e8

Browse files
committed
fix(quality): replace volatile boolean errors with AtomicBoolean
1 parent 58d298b commit 07f06e8

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

methodatlas-discovery-python/src/main/java/org/egothor/methodatlas/discovery/python/PythonTestDiscovery.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public final class PythonTestDiscovery implements TestDiscovery {
120120
private final ReentrantLock poolInitLock = new ReentrantLock();
121121
private PythonEnvironment pythonEnv;
122122
private PythonWorkerPool workerPool;
123-
private volatile boolean errors;
123+
private final AtomicBoolean errors = new AtomicBoolean();
124124

125125
/**
126126
* No-arg constructor required by {@link java.util.ServiceLoader}.
@@ -225,7 +225,7 @@ public Stream<DiscoveredMethod> discover(Path root) throws IOException {
225225
"Python 3.8+ is unavailable — {0} Python test file(s) under {1} will not be scanned.",
226226
new Object[] { files.size(), root });
227227
}
228-
errors = true;
228+
errors.set(true);
229229
return Stream.empty();
230230
}
231231

@@ -239,7 +239,7 @@ public Stream<DiscoveredMethod> discover(Path root) throws IOException {
239239
/** {@inheritDoc} */
240240
@Override
241241
public boolean hadErrors() {
242-
return errors;
242+
return errors.get();
243243
}
244244

245245
/**
@@ -304,7 +304,7 @@ private void processFile(Path root, Path file, List<DiscoveredMethod> result) {
304304
if (LOG.isLoggable(Level.WARNING)) {
305305
LOG.log(Level.WARNING, "Cannot scan Python file: " + file, e);
306306
}
307-
errors = true;
307+
errors.set(true);
308308
return;
309309
}
310310

0 commit comments

Comments
 (0)