Skip to content

Commit

Permalink
Manually include PR internetitem#72
Browse files Browse the repository at this point in the history
  • Loading branch information
cgoIT committed Jun 19, 2020
1 parent d2bfda1 commit d17d541
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ public ElasticsearchWriter(ErrorReporter errorReporter, Settings settings, HttpR
}

private static String slurpErrors(HttpURLConnection urlConnection) {
try {
InputStream stream = urlConnection.getErrorStream();
try (InputStream stream = urlConnection.getErrorStream()) {
if (stream == null) {
return "<no data>";
}

StringBuilder builder = new StringBuilder();
InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
char[] buf = new char[2048];
int numRead;
while ((numRead = reader.read(buf)) > 0) {
builder.append(buf, 0, numRead);

try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
char[] buf = new char[2048];
int numRead;
while ((numRead = reader.read(buf)) > 0) {
builder.append(buf, 0, numRead);
}
}
return builder.toString();
} catch (Exception e) {
Expand Down

0 comments on commit d17d541

Please sign in to comment.