Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6857903

SAXException.initCause() does not correctly set Exception

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_14"
      Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
      Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Upgrading to this release has caused the following code to fail:

              Exception cause = new Exception();
              SAXException e = new SAXException("A SAX exception");
              e.initCause(cause);
              System.out.println(cause == e.getCause());

      Using 6u14 this now prints "false" because initCause(Throwable t); is not overriden in SAXException.

      Taking a step back though, why do you need to store the Exception in SAXException? Why can you not simply delegate all calls to Throwable? I see no logic that SAXException adds on top of Throwable, it just provides a getException() method.

      It seems it last worked under:

      Java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode)

      I've also tried a few other earlier ones (1.6.0_11, 1.6.0_06, 1.5.0_17)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
              Exception cause = new Exception();
              SAXException e = new SAXException("A SAX exception");
              e.initCause(cause);
              System.out.println(cause == e.getCause());

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Should output: "true"
      ACTUAL -
      outputs "false"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import org.xml.sax.SAXException;


      public class Test {

           public static void main(String[] args) {
              Exception cause = new Exception();
              SAXException e = new SAXException("A SAX exception");
              e.initCause(cause);
              System.out.println(cause == e.getCause());
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Do not use the initCause();

      Release Regression From : 6u13
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                aefimov Aleksej Efimov
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: