diff options
author | 2018-09-07 15:32:53 +0000 | |
---|---|---|
committer | 2018-09-07 15:32:53 +0000 | |
commit | 12635b7ef13b0a1b4954ace5f6df5ee3a742f555 (patch) | |
tree | 113e8ffd007e9cacae527145dd79d0debed2c339 /src/main/java/com/att/dmf/mr/utils | |
parent | 9b7af8ef16ca5362d5d43ffe2451f49de87e749a (diff) | |
parent | e696f4e0828d2f26921e233aeede05c4359770a7 (diff) |
Merge "Fix NPE issue in msgrt"
Diffstat (limited to 'src/main/java/com/att/dmf/mr/utils')
-rw-r--r-- | src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java b/src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java index c9a998b..214aac8 100644 --- a/src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java +++ b/src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java @@ -218,7 +218,7 @@ public class DMaaPResponseBuilder { /** * interface used to define write method for outputStream */ - public static abstract interface StreamWriter { + public abstract static interface StreamWriter { /** * abstract method used to write the response * @@ -252,27 +252,20 @@ public class DMaaPResponseBuilder { boolean fResponseEntityAllowed = (!(ctx.getRequest().getMethod().equalsIgnoreCase("HEAD"))); - - OutputStream os = null; - try{ + if (fResponseEntityAllowed) { - os = ctx.getResponse().getOutputStream(); - return os; + try(OutputStream os = ctx.getResponse().getOutputStream()){ + return os; + }catch (Exception e){ + log.error("Exception in getStreamForBinaryResponse",e); + throw new IOException(); + } } else { - os = new NullStream(); - return os; - } - }catch (Exception e){ - throw new IOException(); - - } - finally{ - if(null != os){ - try{ - os.close(); - }catch(Exception e) { - - } + try(OutputStream os = new NullStream()){ + return os; + }catch (Exception e){ + log.error("Exception in getStreamForBinaryResponse",e); + throw new IOException(); } } } |