@@ -72,7 +72,6 @@ public synchronized SplitHttpResponse get(URI uri, FetchOptions options, Map<Str
7272 }
7373 }
7474 public SplitHttpResponse doGet (HttpURLConnection getHttpURLConnection , FetchOptions options , Map <String , List <String >> additionalHeaders ) {
75- InputStreamReader inputStreamReader = null ;
7675 try {
7776 getHttpURLConnection .setRequestMethod ("GET" );
7877 setBasicHeaders (getHttpURLConnection );
@@ -100,28 +99,21 @@ public SplitHttpResponse doGet(HttpURLConnection getHttpURLConnection, FetchOpti
10099 statusMessage = getHttpURLConnection .getResponseMessage ();
101100 }
102101
103- inputStreamReader = new InputStreamReader (getHttpURLConnection .getInputStream ());
102+ InputStreamReader inputStreamReader = new InputStreamReader (getHttpURLConnection .getInputStream ());
104103 BufferedReader br = new BufferedReader (inputStreamReader );
105104 String strCurrentLine ;
106105 StringBuilder bld = new StringBuilder ();
107106 while ((strCurrentLine = br .readLine ()) != null ) {
108107 bld .append (strCurrentLine );
109108 }
110109 String responseBody = bld .toString ();
110+ inputStreamReader .close ();
111111 return new SplitHttpResponse (responseCode ,
112112 statusMessage ,
113113 responseBody ,
114114 getResponseHeaders (getHttpURLConnection ));
115115 } catch (Exception e ) {
116116 throw new IllegalStateException (String .format ("Problem in http get operation: %s" , e ), e );
117- } finally {
118- try {
119- if (inputStreamReader != null ) {
120- inputStreamReader .close ();
121- }
122- } catch (Exception e ) {
123- _log .error (String .format ("Could not close HTTP Stream: %s" , e ), e );
124- }
125117 }
126118 }
127119
0 commit comments