Uploaded image for project: 'Java Mission Control'
  1. Java Mission Control
  2. JMC-7357

Double-Checked Locking in Agent Plugin code

XMLWordPrintable

        The method createSingleton() in PresetRepositoryFactory.java relies on double-checked locking, an incorrect idiom that does not achieve the intended effect.

         

        private static PresetRepository singleton; 
        public static PresetRepository createSingleton() { 
            if (singleton == null) { 
                 synchronized (PresetRepositoryFactory.class) {
                    if (singleton == null) { 
                       singleton = create(); 
                     } 
                   } 
             } 
             return singleton;
        

         

              ghb Guru Hb (Inactive)
              bbanathur Bipin Banathur
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: