summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java')
-rw-r--r--src/main/java/com/att/dmf/mr/utils/DMaaPResponseBuilder.java33
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();
}
}
}