Java Code Examples for javax.xml.stream.XMLStreamException#getNestedException()

The following examples show how to use javax.xml.stream.XMLStreamException#getNestedException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnmarshallerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 2
Source File: UnmarshallerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 3
Source File: UnmarshallerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 4
Source File: UnmarshallerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 5
Source File: UnmarshallerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 6
Source File: UnmarshallerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 7
Source File: UnmarshallerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 8
Source File: UnmarshallerImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static JAXBException handleStreamException(XMLStreamException e) {
    // StAXStreamConnector wraps SAXException to XMLStreamException.
    // XMLStreamException doesn't print its nested stack trace when it prints
    // its stack trace, so if we wrap XMLStreamException in JAXBException,
    // it becomes harder to find out the real problem.
    // So we unwrap them here. But we don't want to unwrap too eagerly, because
    // that could throw away some meaningful exception information.
    Throwable ne = e.getNestedException();
    if(ne instanceof JAXBException) {
        return (JAXBException)ne;
    }
    if(ne instanceof SAXException) {
        return new UnmarshalException(ne);
    }
    return new UnmarshalException(e);
}
 
Example 9
Source File: OverrunStreamingXmlParser.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Override
public Field read() throws IOException, XMLStreamException {
  Field field;
  Utils.checkState(!overrun, "The underlying input stream had an overrun, the parser is not usable anymore");
  countingReader.resetCount();
  limit = getReaderPosition() + maxObjectLen;
  try {
    field = super.read();
    throwIfOverMaxObjectLength();
    initialPosition = getReaderPosition();
  } catch (XMLStreamException ex) {
    if (ex.getNestedException() != null && ex.getNestedException() instanceof OverrunException) {
      overrun = true;
      throw (OverrunException) ex.getNestedException();
    }
    throw ex;
  }
  return field;
}
 
Example 10
Source File: XMLResolverTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testXMLResolver() {
    try {
        XMLInputFactory xifactory = XMLInputFactory.newInstance();
        xifactory.setProperty(XMLInputFactory.RESOLVER, new MyStaxResolver());
        File file = new File(getClass().getResource("XMLResolverTest.xml").getFile());
        String systemId = file.toURI().toString();
        InputStream entityxml = new FileInputStream(file);
        XMLStreamReader streamReader = xifactory.createXMLStreamReader(systemId, entityxml);
        while (streamReader.hasNext()) {
            int eventType = streamReader.next();
            if (eventType == XMLStreamConstants.START_ELEMENT) {
                eventType = streamReader.next();
                if (eventType == XMLStreamConstants.CHARACTERS) {
                    String text = streamReader.getText();
                    Assert.assertTrue(text.contains("replace2"));
                }
            }
        }
    } catch (XMLStreamException ex) {

        if (ex.getNestedException() != null) {
            ex.getNestedException().printStackTrace();
        }
        // ex.printStackTrace() ;
    } catch (Exception io) {
        io.printStackTrace();
    }
}
 
Example 11
Source File: StaxResponseHandler.java    From ibm-cos-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * If the exception was caused by an {@link IOException}, wrap it an another IOE so
 * that it will be exposed to the RetryPolicy.
 */
private Exception handleXmlStreamException(XMLStreamException e) throws Exception {
    if (e.getNestedException() instanceof IOException) {
        return new IOException(e);
    }
    return e;
}
 
Example 12
Source File: DefaultConfigurationBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public void writeXmlConfiguration(final OutputStream output) throws IOException {
    try {
        final XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(output);
        writeXmlConfiguration(xmlWriter);
        xmlWriter.close();
    } catch (final XMLStreamException e) {
        if (e.getNestedException() instanceof IOException) {
            throw (IOException)e.getNestedException();
        }
        Throwables.rethrow(e);
    }
}