Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/util JoistProperties.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/util JoistProperties.java

Author dlr
Full name Daniel Rall
Date 2001-03-20 11:02:07 PST
Message User: dlr
  Date: 01/03/20 11:02:07

  Modified: java/org/joist/util JoistProperties.java
  Log:
  Corrected double-checked locking singleton bug. There's no garauntee
  that the compiler will generate the bytecodes in the right order when
  the lazy initialization style is used. Fortunately, this class
  doesn't necessitate lazy initialization.
  
  Revision Changes Path
  1.9 +8 -20 joist/java/org/joist​/util/JoistPropertie​s.java
  
  Index: JoistProperties.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/util/JoistProp​erties.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JoistProperties.java 2001/02/21 01:35:13 1.8
  +++ JoistProperties.java 2001/03/20 19:02:07 1.9
  @@ -56,20 +56,18 @@
    * Holds onto a properties object to make it available everywhere
    *
    * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
  - * @author <a href="mailto:dlr@dat​aweb-systems.com"​>Daniel Rall</a>
  - * @version $Revision: 1.8 $
  + * @author <a href="mailto:dlr@col​lab.net">Daniel Rall</a>
  + * @version $Revision: 1.9 $
    *
    * Copyright (c) 1999 dataweb systems, inc.
  - * Copyright (c) 1999, 2000 CollabNet, Inc.
  + * Copyright (c) 1999-2001 CollabNet, Inc.
    */
   public class JoistProperties
   {
  - private static final boolean DEBUG = true;
  -
       /**
        * The single instance.
        */
  - private static JoistProperties theInstance = null;
  + private static JoistProperties theInstance = new JoistProperties();
   
       /**
        * Whether the properties have been initialized.
  @@ -82,7 +80,7 @@
       private Properties properties;
   
   
  - /** Constructor.
  + /**
        * Make a private constructor else it's possible to get an instance
        * of this class w/ 'new JoistProperties'. Needed because intent is
        * the singleton pattern w/ this.getInstance( ) as the sole method
  @@ -90,7 +88,9 @@
        */
       private JoistProperties( )
       {
  - super( );
  + super();
  + isInitialized = false;
  + properties = null;
       }
       
       
  @@ -101,18 +101,6 @@
        */
       public static JoistProperties getInstance ()
       {
  - if (theInstance == null)
  - {
  - synchronized (JoistProperties.class)
  - {
  - if (theInstance == null) // if it's _still_ null ;-)
  - {
  - theInstance = new JoistProperties();
  - theInstance.isInitialized = false;
  - theInstance.properties = null;
  - }
  - }
  - }
           return theInstance;
       }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/util JoistProperties.java dlr Daniel Rall 2001-03-20 11:02:07 PST
Messages per page: