Update of /var/cvs/src/org/mmbase/module/core
In directory james.mmbase.org:/tmp/cvs-serv17537

Modified Files:
        MMObjectNode.java 
Log Message:
log warning if you store non serializables


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/module/core


Index: MMObjectNode.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/module/core/MMObjectNode.java,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -b -r1.221 -r1.222
--- MMObjectNode.java   30 Jun 2008 08:29:33 -0000      1.221
+++ MMObjectNode.java   3 Jul 2008 15:53:58 -0000       1.222
@@ -40,7 +40,7 @@
  * @author Eduard Witteveen
  * @author Michiel Meeuwissen
  * @author Ernst Bunders
- * @version $Id: MMObjectNode.java,v 1.221 2008/06/30 08:29:33 michiel Exp $
+ * @version $Id: MMObjectNode.java,v 1.222 2008/07/03 15:53:58 michiel Exp $
  */
 
 public class MMObjectNode implements org.mmbase.util.SizeMeasurable, 
java.io.Serializable  {
@@ -457,6 +457,19 @@
     }
 
     /**
+     * MMObjectNode's are serializable (which is used by e.g. NodeEvent's). So 
all values must be
+     * serializable too.
+     * This methods check that, and logs a warning if not so.
+     * @since MMBase-1.9
+     */
+    protected Object checkSerializable(String fieldName, Object fieldValue) {
+        if (fieldValue != null && (! (fieldValue instanceof Serializable))) {
+            log.warn("Value for " + fieldName + " is not serializable: " + 
fieldValue, new Exception());
+        }
+        return fieldValue;
+    }
+
+    /**
      * Stores a value in the values hashtable.
      * This is a low-level method that circumvents typechecking and the 
triggers of extended classes.
      * You should normally call [EMAIL PROTECTED] #setValue} to change fields.
@@ -471,6 +484,7 @@
             // This is just a hack to make app1 import/export working, 
withough exposing the values map.
             values.remove(fieldName);
         }
+        fieldValue = checkSerializable(fieldName, fieldValue);
         if (checkFieldExistance(fieldName)) {
             values.put(fieldName, fieldValue);
         }
@@ -486,6 +500,7 @@
      */
     private void storeOldValue(String fieldName, Object object) {
         if (! oldValues.containsKey(fieldName)) {
+            object = checkSerializable(fieldName,  object);
             oldValues.put(fieldName, object);
         }
     }
@@ -730,6 +745,7 @@
             if(doc != null) {
                 // store the document inside the field.. much faster...
                 value = doc;
+                value = checkSerializable(fieldName, value);
                 values.put(fieldName, value);
             } else {
                 values.put(fieldName, null);
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to