Skip to content

Commit

Permalink
Merge pull request #138 in OP/openkit-java from bugfix/ONE-44783-fix-…
Browse files Browse the repository at this point in the history
…npe to release/1.4

* commit 'ff156587beb3e5128341f51d51b678c1a0e4d32c':
  Check if InputStream is null to avoid NPE

GitOrigin-RevId: c151fd4bca880c63ac77c75ec4f5bb8c7d0ff415
  • Loading branch information
stefaneberl authored and openkitdt committed Aug 24, 2020
1 parent d006743 commit 38dbaf9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/dynatrace/openkit/protocol/HTTPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private Response handleResponse(RequestType requestType, HttpURLConnection conne
int responseCode = connection.getResponseCode();

String response = responseCode >= 400
? readResponse(connection.getErrorStream()) // error stream is closed in readResponse
? null
: readResponse(connection.getInputStream()); // input stream is closed in readResponse

if (logger.isDebugEnabled()) {
Expand Down Expand Up @@ -399,6 +399,10 @@ int getServerID() {
}

private static String readResponse(InputStream inputStream) throws IOException {
if (inputStream == null) {
return "";
}

StringBuilder responseBuilder = new StringBuilder();

// reading HTTP response
Expand Down

0 comments on commit 38dbaf9

Please sign in to comment.