Wrong exception type when readResolve fails.
--------------------------------------------

                 Key: WICKET-3548
                 URL: https://issues.apache.org/jira/browse/WICKET-3548
             Project: Wicket
          Issue Type: Bug
            Reporter: Maarten Billemont


When readResolve in LazyInitProxyFactory fails because the type cannot be 
found, it dumps the real exception (ClassNotFoundException) and instead throws 
another one:

                                throw new InvalidClassException(type, "could 
not resolve class [" + type +
                                        "] when deserializing proxy");

The InvalidClassException is an invalid exception to throw in this case.  Ref. 
the JavaDoc for this exception:

 * Thrown when the Serialization runtime detects one of the following
 * problems with a Class.
 * <UL>
 * <LI> The serial version of the class does not match that of the class
 *      descriptor read from the stream
 * <LI> The class contains unknown datatypes
 * <LI> The class does not have an accessible no-arg constructor
 * </UL>

The error is not caused by the type class being outdated, containing unknown 
datatypes or having no no-arg constructor.  The developer is mislead into 
thinking the problem is actually something else.

Additionally, the real cause is masked and the real exception (found in "e"), 
is thrown away.  Instead, this method should throw a RuntimeException passing e 
as the cause.  Perhaps RuntimeException itself or an InvalidStateException.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to