Skip to content

Commit

Permalink
added checking entity before using
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rychkov committed Mar 4, 2019
1 parent 50c62e6 commit e074af8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/test/java/com/amihaiemil/zold/mock/ArrayPayloadOf.java
Expand Up @@ -56,17 +56,17 @@ public final class ArrayPayloadOf implements Iterator<JsonObject> {
*/
public ArrayPayloadOf(final ClassicHttpRequest request) {
final HttpEntity entity = request.getEntity();
try (JsonReader reader = Json.createReader(entity.getContent())) {
if (entity != null) {
if (entity != null) {
try (JsonReader reader = Json.createReader(entity.getContent())) {
this.resources =
reader.readArray().getValuesAs(JsonObject.class).iterator();
} else {
this.resources = new ArrayList<JsonObject>().iterator();
} catch (final IOException ex) {
throw new IllegalStateException(
"Cannot read request payload", ex
);
}
} catch (final IOException ex) {
throw new IllegalStateException(
"Cannot read request payload", ex
);
} else {
this.resources = new ArrayList<JsonObject>().iterator();
}
}

Expand Down

0 comments on commit e074af8

Please sign in to comment.