Skip to content

Commit

Permalink
Throw IllegalArgumentException
Browse files Browse the repository at this point in the history
  • Loading branch information
cfournie committed May 2, 2023
1 parent af9bd6d commit e111cc8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private static void articulationPointsRecurse(
if (d < MAX_RECURSION_LEVEL) {
articulationPointsRecurse(a, t.dest, d + 1, depth, low, parent, visited, points);
} else {
continue;
throw new IllegalArgumentException("Exceeded maximum recursion level during graph analysis");
}
childCount++;
if (low[t.dest] >= depth[state]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,32 +684,6 @@ public void testLongTokenStreamStackOverflowError() throws Exception {
TokenStream ts = new CannedTokenStream(tokens.toArray(new Token[0]));
GraphTokenStreamFiniteStrings graph = new GraphTokenStreamFiniteStrings(ts);

Iterator<TokenStream> it = graph.getFiniteStrings();
assertTrue(it.hasNext());
it.next();
assertTrue(it.hasNext());
it.next();
assertFalse(it.hasNext());

int[] points = graph.articulationPoints(); // This will cause a java.lang.StackOverflowError
assertEquals(points[0], 1);
assertEquals(points[1], 3);
assertEquals(points.length, MAX_RECURSION_LEVEL - 2);

assertFalse(graph.hasSidePath(0));
it = graph.getFiniteStrings(0, 1);
assertTrue(it.hasNext());
assertTokenStream(it.next(), new String[] {"fast"}, new int[] {1});
assertFalse(it.hasNext());
Term[] terms = graph.getTerms("field", 0);
assertArrayEquals(terms, new Term[] {new Term("field", "fast")});

assertTrue(graph.hasSidePath(1));
it = graph.getFiniteStrings(1, 3);
assertTrue(it.hasNext());
assertTokenStream(it.next(), new String[] {"wi", "fi"}, new int[] {1, 1});
assertTrue(it.hasNext());
assertTokenStream(it.next(), new String[] {"wifi"}, new int[] {1});
assertFalse(it.hasNext());
assertThrows(IllegalArgumentException.class, () -> graph.articulationPoints());
}
}

0 comments on commit e111cc8

Please sign in to comment.