Do not use ISE in XmlNormalizedNodeBodyWriter 12/110512/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 7 Mar 2024 05:13:03 +0000 (06:13 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 7 Mar 2024 05:13:03 +0000 (06:13 +0100)
We can safely throw IOException, so prefer that to throwing and
unchecked IllegalStateException.

Change-Id: Ib57512055a7a2698db5a568b8856ac5010d52f91
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyWriter.java

index 54c044e311473d871e4cb01b06e24a798c6363ac..4b3dbc61992078199b23ab540d5f6f917b5734c5 100644 (file)
@@ -88,12 +88,12 @@ public final class XmlNormalizedNodeBodyWriter extends AbstractNormalizedNodeBod
     }
 
     private static XMLStreamWriter createXmlWriter(final OutputStream entityStream,
-            final @Nullable PrettyPrintParam prettyPrint) {
+            final @Nullable PrettyPrintParam prettyPrint) throws IOException {
         final XMLStreamWriter xmlWriter;
         try {
             xmlWriter = XML_FACTORY.createXMLStreamWriter(entityStream, StandardCharsets.UTF_8.name());
         } catch (XMLStreamException | FactoryConfigurationError e) {
-            throw new IllegalStateException(e);
+            throw new IOException(e);
         }
 
         return prettyPrint != null && prettyPrint.value() ? new IndentingXMLStreamWriter(xmlWriter) : xmlWriter;