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

Exceptions: getCause() returns null instead of specified cause

XMLWordPrintable

    • b44
    • generic
    • generic
    • Verified



      Name: eaR10174 Date: 03/10/2004


      When XPath exceptions are created by the constructor with the specified cause
      the method getCause() returns null instead of the specified cause.

      The bug affects the new JCK1.5-beta1 tests:

        api/javax_xml/xpath/XPathException/index.html#Ctor[Ctor001]
        api/javax_xml/xpath/XPathExpressionException/index.html#Ctor[Ctor001]
        api/javax_xml/xpath/XPathFactoryConfigurationException/index.html#Ctor[Ctor001]
        api/javax_xml/xpath/XPathFunctionException/index.html#Ctor[Ctor001]

      The sample is provided below; it fails on JDK 1.5.0-beta-b41.
      ------------------------------------test.java-----------------------------
      import javax.xml.xpath.XPathException;
      import javax.xml.xpath.XPathExpressionException;
      import javax.xml.xpath.XPathFactoryConfigurationException;
      import javax.xml.xpath.XPathFunctionException;

      public class test {

           public static void main(String argv[]) {
               test t = new test();
               t.run01();
               t.run02();
               t.run03();
               t.run04();
           }

           public void run01() {
               Exception e = new Exception("test");

               XPathException xpathException = new XPathException(e);

               if (!e.equals(xpathException.getCause())) {
                   System.out.println("run01 failed. Returned cause: " +
                       xpathException.getCause());
               } else {
                   System.out.println("run01 OK");
               }
           }

           public void run02() {
               Exception e = new Exception("test");

               XPathExpressionException xpathException = new XPathExpressionException(e);

               if (!e.equals(xpathException.getCause())) {
                   System.out.println("run02 failed. Returned cause: " +
                       xpathException.getCause());
               } else {
                   System.out.println("run02 OK");
               }
           }

           public void run03() {
               Exception e = new Exception("test");

               XPathFactoryConfigurationException xpathException =
                   new XPathFactoryConfigurationException(e);

               if (!e.equals(xpathException.getCause())) {
                   System.out.println("run03 failed. Returned cause: " +
                       xpathException.getCause());
               } else {
                   System.out.println("run03 OK");
               }
           }

           public void run04() {
               Exception e = new Exception("test");

               XPathFunctionException xpathException = new XPathFunctionException(e);

               if (!e.equals(xpathException.getCause())) {
                   System.out.println("run04 failed. Returned cause: " +
                       xpathException.getCause());
               } else {
                   System.out.println("run04 OK");
               }
           }
      }
      --------------------------------------------------------------------------
      % java -showversion test
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b41)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b41, mixed mode)

      run01 failed. Returned cause: null
      run02 failed. Returned cause: null
      run03 failed. Returned cause: null
      run04 failed. Returned cause: null
      --------------------------------------------------------------------------

      ======================================================================

      Name: eaR10174 Date: 03/11/2004


      The tests do not fail on jdk1.5 builds prior jdk1.5.0-beta2-b41.

      ======================================================================

            busersunw Btplusnull User (Inactive)
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: