You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/10/30 06:57:03 UTC

svn commit: r589967 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleMapAccessor.java

Author: jonesde
Date: Mon Oct 29 22:57:02 2007
New Revision: 589967

URL: http://svn.apache.org/viewvc?rev=589967&view=rev
Log:
Small change to not add null values to lists, will always throw an NPE

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleMapAccessor.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleMapAccessor.java?rev=589967&r1=589966&r2=589967&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleMapAccessor.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleMapAccessor.java Mon Oct 29 22:57:02 2007
@@ -214,14 +214,17 @@
                 lst = FastList.newInstance();
                 base.put(this.extName, lst);
             }
-            //if brackets are empty, append to list
-            if (this.isAddAtEnd) {
-                lst.add(value);
-            } else {
-                if (this.isAddAtIndex) {
-                    lst.add(this.listIndex, value);
+            //if brackets are empty, append to list, but only if it's not null (avoid NPEs with FastList)
+            if (value != null) {
+            	// note that we are checking for null AFTER checking/creating the list itself, so that it will exist after referenced the first time
+                if (this.isAddAtEnd) {
+                    lst.add(value);
                 } else {
-                    lst.set(this.listIndex, value);
+                    if (this.isAddAtIndex) {
+                        lst.add(this.listIndex, value);
+                    } else {
+                        lst.set(this.listIndex, value);
+                    }
                 }
             }
         } else {