@@ -96,7 +96,7 @@ public String get(final String urlAsString) {
96
96
} catch (SocketTimeoutException e ) {
97
97
throw new ApiTimeoutException ("Timeout: Could not establish connection for " + connectTimeout + " millis" , e );
98
98
} catch (Exception e ) {
99
- throw new ConnectionException (e .getLocalizedMessage (), e );
99
+ throw new ConnectionException (e .getMessage (), e );
100
100
}
101
101
}
102
102
@@ -126,7 +126,7 @@ public String post(final String urlAsString, final String dataToPost) {
126
126
} catch (SocketTimeoutException e ) {
127
127
throw new ApiTimeoutException ("Timeout: Could not establish connection for " + connectTimeout + " millis" , e );
128
128
} catch (Exception e ) {
129
- throw new ConnectionException (e .getLocalizedMessage (), e );
129
+ throw new ConnectionException (e .getMessage (), e );
130
130
}
131
131
}
132
132
@@ -136,8 +136,6 @@ private String readData(final HttpURLConnection connection) throws IOException {
136
136
String inputLine ;
137
137
while ((inputLine = in .readLine ()) != null )
138
138
content .append (inputLine );
139
-
140
- in .close ();
141
139
}
142
140
143
141
return content .toString ();
@@ -146,11 +144,11 @@ private String readData(final HttpURLConnection connection) throws IOException {
146
144
private InputStreamReader getStreamReader (final HttpURLConnection connection ) throws IOException {
147
145
switch (String .valueOf (connection .getContentEncoding ())) {
148
146
case "gzip" :
149
- return new InputStreamReader (new GZIPInputStream (connection .getInputStream ()), "utf-8" );
147
+ return new InputStreamReader (new GZIPInputStream (connection .getInputStream ()), StandardCharsets . UTF_8 );
150
148
case "deflate" :
151
- return new InputStreamReader (new InflaterInputStream (connection .getInputStream ()), "utf-8" );
149
+ return new InputStreamReader (new InflaterInputStream (connection .getInputStream ()), StandardCharsets . UTF_8 );
152
150
default :
153
- return new InputStreamReader (connection .getInputStream (), "utf-8" );
151
+ return new InputStreamReader (connection .getInputStream (), StandardCharsets . UTF_8 );
154
152
}
155
153
}
156
154
}
0 commit comments