Author: michiel
Date: 2009-06-05 09:10:22 +0200 (Fri, 05 Jun 2009)
New Revision: 35741

Modified:
   mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/Related.java
Log:
Don't whine if you happend to provide null as a node. Null has no relations, we 
know that.

Modified: 
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/Related.java
===================================================================
--- 
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/Related.java    
    2009-06-05 07:06:34 UTC (rev 35740)
+++ 
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/processors/Related.java    
    2009-06-05 07:10:22 UTC (rev 35741)
@@ -146,16 +146,22 @@
     public static class Getter extends AbstractProcessor {
         private static final long serialVersionUID = 1L;
 
-        public Object process(Node node, Field field, Object value) {
+        public Object process(final Node node, final Field field, final Object 
value) {
             if (log.isDebugEnabled()) {
                 log.debug("getting "  + node);
             }
+            if (node == null) {
+                // null cannot be related to anything
+                return null;
+            }
             NodeQuery relations = getRelationsQuery(node);
             NodeList rl = relations.getNodeManager().getList(relations);
             if (rl.size() == 0) {
+                log.debug("Not found, returning null");
                 return null;
             } else {
                 Relation relation = rl.getNode(0).toRelation();
+                log.debug("Found " + relation);
                 if (relation.getSource().getNumber() == node.getNumber()) {
                     return relation.getDestination();
                 } else {

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to