-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
Currently the code reads
if(importsDetermined.compareAndSet(false, true)) {
pathsToImports = new HashMap<String, List<DependencyImport>>();
for(Dependency dependency : dependencies) {
which causes an NPE if there are no dependencies. Access to the AtomicBoolean is not synchronized, so competing threads will see a different value of importsDetermined but the returned set may still be different. I believe the intention was to atomically initialize the set.
The code should probably read
synchronized (importsDetermined) {
if(importsDetermined.compareAndSet(false, true)) {
pathsToImports = new HashMap<String, List<DependencyImport>>();
if (dependencies != null)
{
for(Dependency dependency : dependencies) {