You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Antoine Angénieux (JIRA)" <ji...@apache.org> on 2008/04/02 18:19:24 UTC

[jira] Created: (WICKET-1474) Page serialization bug, when a class hierarchy doesn't implement Serializable in a "consistent" way

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.


[jira] Updated: (WICKET-1474) Page serialization bug, when a class hierarchy doesn't implement Serializable in a "consistent" way

Posted by "Antoine Angénieux (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antoine Angénieux updated WICKET-1474:
--------------------------------------

    Attachment: quickstart.tar.gz

A quickstart exposing the bug.

Simply build and run in jetty with mvn jetty:run
Go the the home page
Click on the link to the form page
On the form page :
Click on the submit link
Click on the back button
Click on the submit link again, and there is the NullPointer

At no stage will wicket ever complain about serialization issues...


> 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.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.3.0-beta1, 1.3.0-beta2, 1.3.0-beta3, 1.3.0-beta4, 1.3.0-rc1, 1.3.0-rc2, 1.3.0-final, 1.3.1, 1.3.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
>         Attachments: quickstart.tar.gz
>
>
> 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.


[jira] Closed: (WICKET-1474) Page serialization bug, when a class hierarchy doesn't implement Serializable in a "consistent" way

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner closed WICKET-1474.
-----------------------------------

    Resolution: Won't Fix

this is something we cant fix...

because this is how serialization works
On the first none serializeable class a default constructor is called and that one is responsible for creating the object.
Then the sub class can if it can access fill in also the fields of its super. But thats just it.

> 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.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.3.0-beta1, 1.3.0-beta2, 1.3.0-beta3, 1.3.0-beta4, 1.3.0-rc1, 1.3.0-rc2, 1.3.0-final, 1.3.1, 1.3.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
>         Attachments: quickstart.tar.gz
>
>
> 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.