Author: ehillenius
Date: Sun Feb 11 23:30:51 2007
New Revision: 506347
URL: http://svn.apache.org/viewvc?view=rev&rev=506347
Log:
some small improvements (WICKET-265)
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/io/SerializableChecker.java
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/lang/Objects.java
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/io/SerializableChecker.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/io/SerializableChecker.java?view=diff&rev=506347&r1=506346&r2=506347
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/io/SerializableChecker.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/io/SerializableChecker.java
Sun Feb 11 23:30:51 2007
@@ -287,13 +287,21 @@
/** current full field description. */
private String fieldDescription;
+ /** Exception that should be set as the cause when throwing a new
exception. */
+ private NotSerializableException exception;
+
/**
* Construct.
*
+ * @param exception
+ * exception that should be set as the cause when throwing a
new
+ * exception
+ *
* @throws IOException
*/
- public SerializableChecker() throws IOException
+ public SerializableChecker(NotSerializableException exception) throws
IOException
{
+ this.exception = exception;
}
/**
@@ -324,7 +332,7 @@
if (!(obj instanceof Serializable))
{
throw new
WicketNotSerializableException(toPrettyPrintedStack(obj.getClass().getName())
- .toString(), new
NotSerializableException(obj.getClass().getName()));
+ .toString(), exception);
}
final ObjectStreamClass desc;
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/lang/Objects.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/lang/Objects.java?view=diff&rev=506347&r1=506346&r2=506347
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/lang/Objects.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/util/lang/Objects.java
Sun Feb 11 23:30:51 2007
@@ -20,6 +20,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamClass;
@@ -1046,28 +1047,28 @@
}
catch (IOException e)
{
- if (SerializableChecker.isAvailable())
+ if ((e instanceof NotSerializableException) &&
SerializableChecker.isAvailable())
{
// trigger serialization again, but this time
gather some more
// info
try
{
- new
SerializableChecker().writeObject(object);
+ new
SerializableChecker((NotSerializableException)e).writeObject(object);
+ // if we get here, we didn't fail,
while we should; print
+ // out the message contains a pointer
to where in the object
+ // hierarchy to trouble maker is
+ logSerializationException(object, e);
}
catch (Exception e1)
{
// the message contains a pointer to
where in the object
// hierarchy to trouble maker is
- log.error("Error serializing object " +
object.getClass() + " [object="
- + object + "]", e1);
+ logSerializationException(object, e1);
}
}
else
{
- // the message contains a pointer to where in
the object
- // hierarchy to trouble maker is
- log.error("Error serializing object " +
object.getClass() + " [object=" + object
- + "]", e);
+ logSerializationException(object, e);
}
}
return null;
@@ -1138,6 +1139,11 @@
}
}
return result;
+ }
+
+ private static void logSerializationException(final Object object,
Exception e)
+ {
+ log.error("Error serializing object " + object.getClass() + "
[object=" + object + "]", e);
}
/**