Page serialization bug, when a class hierarchy doesn't implement Serializable
in a "consistent" way
---------------------------------------------------------------------------------------------------
Key: WICKET-1474
URL: https://issues.apache.org/jira/browse/WICKET-1474
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.3.2, 1.3.1, 1.3.0-final, 1.3.0-rc2, 1.3.0-rc1,
1.3.0-beta4, 1.3.0-beta3, 1.3.0-beta2, 1.3.0-beta1, 1.2.7, 1.2.6, 1.2.5, 1.2.4,
1.2.3, 1.2.2, 1.3.3
Environment: Any (tried on Windows XP, Vista and Linux with JDK 1.5
and 1.6 and on both Tomcat 6.0 and Jetty 6.1.9
Reporter: Antoine Angénieux
Priority: Minor
Here is when things go messy :
I have an interface that does not extend Serializable and a base abstract class
implementing the interface, but is still not serializable. Let's call these
INonSerializable and ANonSerializable.
This abstract class holds reference to a private object, and exposes a method
which uses internally the private object reference, eg :
public abstract class ANonSerializable implements INonSerializable {
private Integer nb;
public ANonSerializable() {
super();
}
public void setNb(Integer nb) {
this.nb = nb;
}
public String getValue() {
return nb.toString();
}
}
An important note here is that the reference to the nb property is not defined
in the constructor, but explicitly set by clients of this class !
Then, I have a concrete subclass of that abstract class that implements
Serializable, let's call it BuggyClass, eg :
public class BuggyClass extends ANonSerializable implements Serializable {
public BuggyClass() {
super();
}
public void echo() {
// Calls the parent method using
System.out.println(getValue());
}
}
Now, if we have a statefull page, which contains for example a form and which
changes its structure on submit events (to cause a version change on each
submit)
containing an instance of BuggyClass and calling its echo() method in the
onSubmit(), and that this page instance comes from the diskstore, a null
pointer exception will be thrown, because the private field nb from the
ANonSerializableClass won't have been restored properly
I've attached a quickstart to this issue for more clarity ;)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.