Properly close stream writer 69/85269/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 20 Oct 2019 09:23:48 +0000 (11:23 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 20 Oct 2019 09:24:44 +0000 (11:24 +0200)
Failing to close the streamwriter means it will not output its
trailer in all cases. Fix that.

Change-Id: I218cea9ff61fbc7c33ccab75638dda9a4f20b391
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java

index 5561949f5e110ddd611ba4c90f06db29959411b2..ec2e9674960f511c5686e478abff755910c3d613 100644 (file)
@@ -276,6 +276,12 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco
             LOG.warn("Error writing error response body", e);
         }
 
+        try {
+            streamWriter.close();
+        } catch (IOException e) {
+            LOG.warn("Failed to close stream writer", e);
+        }
+
         try {
             return outStream.toString(StandardCharsets.UTF_8.name());
         } catch (UnsupportedEncodingException e) {