svn commit: r17358 - trunk/src/argouml-app/src/org/argouml/cognitive/ui/PriorityNode.java
Michiel van der Wulp <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mvw
Date: 2009-09-28 23:48:46-0700
New Revision: 17358
Modified:
trunk/src/argouml-app/src/org/argouml/cognitive/ui/PriorityNode.java
Log:
Corrected a potential problem located by FindBugs :
File: PriorityNode.java, Line: 70, Type: LI_LAZY_INIT_UPDATE_STATIC, Priority: High, Category: CORRECTNESS
Incorrect lazy initialization and update of static field
This method contains an unsynchronized lazy initialization of a static field. After the field is set, the object stored into that location is further accessed. The setting of the field is visible to other threads as soon as it is set. If the futher accesses in the method that set the field serve to initialize the object, then you have a very serious multithreading bug, unless something else prevents any other thread from accessing the stored object until it is fully initialized.
Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ui/PriorityNode.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ui/PriorityNode.java?view=diff&pathrev=17358&r1=17357&r2=17358
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ui/PriorityNode.java (original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ui/PriorityNode.java 2009-09-28 23:48:46-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2009 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -68,13 +68,16 @@
*/
public static List<PriorityNode> getPriorityList() {
if (priorities == null) {
- priorities = new ArrayList<PriorityNode>();
- priorities.add(new PriorityNode(HIGH,
+ List<PriorityNode> p = new ArrayList<PriorityNode>();
+ p.add(new PriorityNode(HIGH,
ToDoItem.HIGH_PRIORITY));
- priorities.add(new PriorityNode(MEDIUM,
+ p.add(new PriorityNode(MEDIUM,
ToDoItem.MED_PRIORITY));
- priorities.add(new PriorityNode(LOW,
+ p.add(new PriorityNode(LOW,
ToDoItem.LOW_PRIORITY));
+ /* Correct lazy initialization of static field
+ * without further updates: */
+ priorities = p;
}
return priorities;
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2401480
To unsubscribe from this discussion, e-mail: [[email protected]].