Skip to content

Commit c3ddbda

Browse files
thewheatchoran
authored andcommitted
Allow parsing of responses from DELETE requests (#248)
1 parent dd4f2ef commit c3ddbda

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

intercom-java/src/main/java/io/intercom/api/HttpClient.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,18 @@ private <T> T handleSuccess(JavaType javaType, HttpURLConnection conn, int respo
178178
}
179179

180180
private boolean shouldSkipResponseEntity(JavaType javaType, HttpURLConnection conn, int responseCode) {
181-
return responseCode == 204 || Void.class.equals(javaType.getRawClass()) || "DELETE".equals(conn.getRequestMethod());
181+
return responseCode == 204 || Void.class.equals(javaType.getRawClass());
182182
}
183183

184184
private <T> T readEntity(HttpURLConnection conn, int responseCode, JavaType javaType) throws IOException {
185185
final InputStream entityStream = conn.getInputStream();
186186
try {
187+
final String text = CharStreams.toString(new InputStreamReader(entityStream));
187188
if (logger.isDebugEnabled()) {
188-
final String text = CharStreams.toString(new InputStreamReader(entityStream));
189189
logger.debug("api server response status[{}] --\n{}\n-- ", responseCode, text);
190-
return objectMapper.readValue(text, javaType);
191-
} else {
192-
return objectMapper.readValue(entityStream, javaType);
193190
}
191+
if (text.isEmpty()) return null;
192+
return objectMapper.readValue(text, javaType);
194193
} finally {
195194
IOUtils.closeQuietly(entityStream);
196195
}

0 commit comments

Comments
 (0)