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

XPathException.getMessage() returns wrapped exception string instead of null

    XMLWordPrintable

Details

    • b26
    • generic
    • generic
    • Verified

    Description

      Name: eaR10174 Date: 10/22/2003


        The method javax.xml.xpath.XPathException.getMessage() returns a string representation
      of the wrapped exception (see test.java below) in case when an instance of XPathException
      is create by the constructor
        
           public XPathException(String message, Throwable e)

      with the parameters: message = null, e = Exception("test").

      This behavior is not specified in the javadoc of the class XPathException, so the value
      null is expected to be returned.

        The bug appears in jdk1.5.0beta-b24 and affects a new JCK1.5 test:
        
          api/javax_xml/xpath/XPathException/index.html#Ctor[Ctor007]

      ------------------------------------test.java-----------------------------
      import javax.xml.xpath.XPathException;

      public class test {

          public static void main (String[] args) {
              XPathException xPathException = new XPathException(null, new Exception("test"));
              
              String message = xPathException.getMessage();
              if (message != null) {
                  System.out.println("Expected null. Returned: " + message);
              } else {
                  System.out.println("OK.");
              }
          }
      }
      --------------------------------------------------------------------------
      % java -showversion test
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b24)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b24, mixed mode)

      Expected null. Returned: java.lang.Exception: test
      --------------------------------------------------------------------------

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

      Attachments

        Activity

          People

            jsuttorsunw Jeff Suttor (Inactive)
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: