Uploaded image for project: 'JBoss Modules'
  1. JBoss Modules
  2. MODULES-17

Synch and NPE issue in Module getPathsToImports/Exports

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0.Beta2
    • 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) {

              dlloyd@redhat.com David Lloyd
              tdiesler@redhat.com Thomas Diesler
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: