https://sonar.onap.org/project/issues?id=org.onap.dmaap.messagerouter.msgrtr%3Amsgrtr&open=AWU41WfQwGn37JfbyHsq&resolved=false&severities=BLOCKER&types=BUG
Issue-ID: DMAAP-748
Change-Id: Ie21e69a8ff69aab20dcbd1ec0f6db947db55271a
Signed-off-by: Amaresh Kumar <kamaresh@in.ibm.com>
*/
public static void respondOkWithStream(DMaaPContext ctx, String mediaType, StreamWriter writer) throws IOException {
ctx.getResponse().setStatus(200);
- OutputStream os = getStreamForBinaryResponse(ctx, mediaType);
- writer.write(os);
- os.close();
-
+ try(OutputStream os = getStreamForBinaryResponse(ctx, mediaType)) {
+ writer.write(os);
+ }
+
}