Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-3548

Wrong exception type when readResolve fails.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.4.17, 1.5-RC3
    • None
    • None

    Description

      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.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            lhunath Maarten Billemont
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: