Author: bpapez
Date: Fri Jan 11 13:17:46 2008
New Revision: 19492

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19492&repname=
=3Djahia
Log:
Prevent NPE when having empty container structures, just log a warning

Modified:
    branches/JAHIA-4-1-BRANCH/src/java/org/jahia/data/containers/JahiaConta=
inerDefinition.java

Modified: branches/JAHIA-4-1-BRANCH/src/java/org/jahia/data/containers/Jahi=
aContainerDefinition.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-4-1-BR=
ANCH/src/java/org/jahia/data/containers/JahiaContainerDefinition.java&rev=
=3D19492&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-4-1-BRANCH/src/java/org/jahia/data/containers/JahiaConta=
inerDefinition.java (original)
+++ branches/JAHIA-4-1-BRANCH/src/java/org/jahia/data/containers/JahiaConta=
inerDefinition.java Fri Jan 11 13:17:46 2008
@@ -207,7 +207,7 @@
     public Enumeration getStructure( String dummy, int pageDefID, int type=
Flag ) {
         Vector structure;
         JahiaContainerSubDefinition theSubDef =3D getSubDef( pageDefID );
-        if (theSubDef !=3D null) {
+        if (theSubDef !=3D null && theSubDef.getStructure() !=3D null) {
             structure =3D theSubDef.getStructure();
         } else {
             return (new Vector()).elements();
@@ -333,13 +333,19 @@
             structure =3D null;
         }
 =

-        if ((struct =3D=3D null) || (structure =3D=3D null)) {
-            // compares null
-            logger.warn(name + ":Structure non-existant in memory, must lo=
ad from database");
-            return true;
+        if (struct =3D=3D null || structure =3D=3D null) {
+            if (struct =3D=3D null && structure =3D=3D null
+                    || (struct !=3D null && struct.isEmpty())) {
+                logger.warn(name + ":Container structure is EMPTY!!");
+                return false;
+            } else {
+                // compares null
+                logger.warn(name + ":Structure non-existant in memory, mus=
t load from database");
+                return true;
+            }
         } else if (struct.size() !=3D structure.size()) {
             // compares sizes
-            logger.warn(name + ":Size are not equal (cur=3D" +
+            logger.warn(name + ":Size is not equal (cur=3D" +
                                  Integer.toString(structure.size()) + ", n=
ew=3D" + Integer.toString(struct.size()) + ")");
             return true;
         } else {

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to