prevent possible NPE

This commit is contained in:
Athou
2013-07-26 15:34:02 +02:00
parent e8bfecc07d
commit 080c0b48d0

View File

@@ -134,14 +134,17 @@ public class HttpGetter {
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
byte[] content = null; byte[] content = null;
String contentType = null;
if (entity != null) { if (entity != null) {
content = EntityUtils.toByteArray(entity); content = EntityUtils.toByteArray(entity);
if (entity.getContentType() != null) {
contentType = entity.getContentType().getValue();
}
} }
long duration = System.currentTimeMillis() - start; long duration = System.currentTimeMillis() - start;
Header contentType = entity.getContentType(); result = new HttpResult(content, contentType, lastModifiedHeader == null ? null : lastModifiedHeader.getValue(),
result = new HttpResult(content, contentType == null ? null : contentType.getValue(), lastModifiedHeader == null ? null eTagHeader == null ? null : eTagHeader.getValue(), duration);
: lastModifiedHeader.getValue(), eTagHeader == null ? null : eTagHeader.getValue(), duration);
} finally { } finally {
client.getConnectionManager().shutdown(); client.getConnectionManager().shutdown();
} }