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

Exception message missing in XMLStreamException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • xml
    • b90
    • generic
    • generic

      When any Exception is wrapped into an XMLStreamException, message of the original exception is not forwarded up to the stack. This results into a null message where developer doesn't have a clue about what has gone wrong.
      -----------------------------------------------------------------
      import javax.xml.stream.*;
      import java.io.*;

      import junit.framework.TestCase;
      import junit.textui.TestRunner;


      public class ExceptionTest extends TestCase{
          
          public ExceptionTest(String name) {
              super(name);
          }
          
          public static void main(String [] args) {
              TestRunner.run(ExceptionTest.class);
          }
          
          public void testException(){
              
              final String EXPECTED_OUTPUT = "Test XMLStreamException";
              try{
                  Exception ex = new IOException("Test XMLStreamException");
                  throw new XMLStreamException(ex);
              } catch(XMLStreamException e){
                  assertTrue("XMLStreamException does not contain the message " +
                          "of the wrapped exception",
                          e.getMessage().contains(EXPECTED_OUTPUT));
              }
          }
      }
      -------------------------------------------------------------------------------

            sreddysunw Sunitha Reddy (Inactive)
            sreddysunw Sunitha Reddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: