Author: ivaynberg
Date: Thu Oct 21 04:39:59 2010
New Revision: 1025820

URL: http://svn.apache.org/viewvc?rev=1025820&view=rev
Log:
fixed the rare but seriously annoying stack overflow in serializable checker. 
had to do with checking objects that override serialization.

Modified:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/io/SerializableChecker.java

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/io/SerializableChecker.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/io/SerializableChecker.java?rev=1025820&r1=1025819&r2=1025820&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/io/SerializableChecker.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/io/SerializableChecker.java
 Thu Oct 21 04:39:59 2010
@@ -34,6 +34,7 @@ import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Stack;
 
 import org.apache.wicket.Component;
 import org.apache.wicket.WicketRuntimeException;
@@ -302,6 +303,8 @@ public final class SerializableChecker e
        /** Exception that should be set as the cause when throwing a new 
exception. */
        private final NotSerializableException exception;
 
+       private final Stack<Object> stack = new Stack<Object>();
+
        /**
         * Construct.
         * 
@@ -337,6 +340,29 @@ public final class SerializableChecker e
                        return;
                }
 
+               if (stack.contains(obj))
+               {
+                       return;
+               }
+
+               stack.push(obj);
+               try
+               {
+                       internalCheck(obj);
+               }
+               finally
+               {
+                       stack.pop();
+               }
+       }
+
+       private void internalCheck(Object obj)
+       {
+               if (obj == null)
+               {
+                       return;
+               }
+
                Class<?> cls = obj.getClass();
                nameStack.add(simpleName);
                traceStack.add(new TraceSlot(obj, fieldDescription));


Reply via email to