Skip to content

Commit 3470b0c

Browse files
author
srife001c
committed
Add check for null InputStream to prevent infinite loop
1 parent c7b7575 commit 3470b0c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

blueprints-core/src/main/java/com/tinkerpop/blueprints/util/io/graphson/GraphSONReader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public static void inputGraph(final Graph inputGraph, final String filename, int
136136
public static void inputGraph(final Graph inputGraph, final InputStream jsonInputStream, int bufferSize,
137137
final Set<String> edgePropertyKeys, final Set<String> vertexPropertyKeys) throws IOException {
138138

139+
if (jsonInputStream == null) {
140+
throw new IllegalArgumentException("InputStream must not be null");
141+
}
142+
139143
final JsonParser jp = jsonFactory.createJsonParser(jsonInputStream);
140144

141145
// if this is a transactional graph then we're buffering

blueprints-test/src/test/java/com/tinkerpop/blueprints/util/io/graphson/GraphSONReaderTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ public void inputGraphCompactFullCycleBroken() throws IOException {
308308

309309
}
310310

311+
@Test(expected = IllegalArgumentException.class)
312+
public void inputStreamIsNull() throws IOException {
313+
TinkerGraph graph = new TinkerGraph();
314+
InputStream inputStream = null;
315+
GraphSONReader.inputGraph(graph, inputStream);
316+
}
317+
311318

312319
private int getIterableCount(Iterable elements) {
313320
int counter = 0;

0 commit comments

Comments
 (0)