33import java .io .BufferedReader ;
44import java .io .IOException ;
55import java .io .InputStreamReader ;
6+ import java .io .OutputStream ;
67import java .io .OutputStreamWriter ;
78import java .net .HttpURLConnection ;
8- import java .net .MalformedURLException ;
99import java .nio .charset .Charset ;
1010import java .util .Iterator ;
1111import java .util .Map ;
@@ -56,7 +56,8 @@ public String execute(String url, String payload,
5656 ClientActionRequiredException {
5757
5858 String successResponse = Constants .EMPTY_STRING , errorResponse = Constants .EMPTY_STRING ;
59- InputStreamReader iSR = null ;
59+ InputStreamReader isr = null ;
60+ OutputStream os = null ;
6061 BufferedReader reader = null ;
6162 OutputStreamWriter writer = null ;
6263 connection .setRequestProperty ("Content-Length" , ""
@@ -70,16 +71,16 @@ public String execute(String url, String payload,
7071 do {
7172 try {
7273 if ("POST" .equalsIgnoreCase (connection .getRequestMethod ())) {
73- writer = new OutputStreamWriter (
74- this . connection . getOutputStream () ,
74+ os = this . connection . getOutputStream ();
75+ writer = new OutputStreamWriter ( os ,
7576 Charset .forName (Constants .ENCODING_FORMAT ));
7677 writer .write (payload );
7778 writer .flush ();
7879 }
7980 int responsecode = connection .getResponseCode ();
80- iSR = new InputStreamReader (connection .getInputStream (),
81+ isr = new InputStreamReader (connection .getInputStream (),
8182 Constants .ENCODING_FORMAT );
82- reader = new BufferedReader (iSR );
83+ reader = new BufferedReader (isr );
8384 if (responsecode >= 200 && responsecode < 300 ) {
8485 successResponse = read (reader );
8586 LoggingManager .debug (HttpConnection .class ,
@@ -136,13 +137,17 @@ public String execute(String url, String payload,
136137 if (writer != null ) {
137138 writer .close ();
138139 }
139- if (iSR != null ) {
140- iSR .close ();
140+ if (isr != null ) {
141+ isr .close ();
142+ }
143+ if (os != null ) {
144+ os .close ();
141145 }
142146 } finally {
143147 reader = null ;
144148 writer = null ;
145- iSR = null ;
149+ isr = null ;
150+ os = null ;
146151 }
147152 }
148153 return successResponse ;
0 commit comments