From b616ff52eb9082261294057dea43cccd1a1818bc Mon Sep 17 00:00:00 2001 From: Chris Fournier Date: Mon, 12 Jun 2023 11:01:00 -0400 Subject: [PATCH] Address reviewer comments --- lucene/CHANGES.txt | 4 ++-- .../lucene/util/graph/GraphTokenStreamFiniteStrings.java | 3 ++- .../util/graph/TestGraphTokenStreamFiniteStrings.java | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 623e255e2fff..48626a8349c9 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -86,8 +86,6 @@ Bug Fixes * GITHUB#12220: Hunspell: disallow hidden title-case entries from compound middle/end -* LUCENE-10181: Restrict GraphTokenStreamFiniteStrings#articulationPointsRecurse recursion depth. (Chris Fournier) - Other --------------------- @@ -192,6 +190,8 @@ Bug Fixes * GITHUB#12352: [Tessellator] Improve the checks that validate the diagonal between two polygon nodes so the resulting polygons are valid counter clockwise polygons. (Ignacio Vera) +* LUCENE-10181: Restrict GraphTokenStreamFiniteStrings#articulationPointsRecurse recursion depth. (Chris Fournier) + Other --------------------- (No changes) diff --git a/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java b/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java index 4a00119cc30b..11bf116a796e 100644 --- a/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java +++ b/lucene/core/src/java/org/apache/lucene/util/graph/GraphTokenStreamFiniteStrings.java @@ -275,7 +275,8 @@ private static void articulationPointsRecurse( if (d < MAX_RECURSION_LEVEL) { articulationPointsRecurse(a, t.dest, d + 1, depth, low, parent, visited, points); } else { - throw new IllegalArgumentException("Exceeded maximum recursion level during graph analysis"); + throw new IllegalArgumentException( + "Exceeded maximum recursion level during graph analysis"); } childCount++; if (low[t.dest] >= depth[state]) { diff --git a/lucene/core/src/test/org/apache/lucene/util/graph/TestGraphTokenStreamFiniteStrings.java b/lucene/core/src/test/org/apache/lucene/util/graph/TestGraphTokenStreamFiniteStrings.java index 2cbf41ea605e..4df3a0eb029a 100644 --- a/lucene/core/src/test/org/apache/lucene/util/graph/TestGraphTokenStreamFiniteStrings.java +++ b/lucene/core/src/test/org/apache/lucene/util/graph/TestGraphTokenStreamFiniteStrings.java @@ -16,8 +16,6 @@ */ package org.apache.lucene.util.graph; -import static org.apache.lucene.util.automaton.Operations.MAX_RECURSION_LEVEL; - import java.util.ArrayList; import java.util.Iterator; import org.apache.lucene.analysis.TokenStream; @@ -677,13 +675,13 @@ public void testLongTokenStreamStackOverflowError() throws Exception { }; // Add in too many tokens to get a high depth graph - for (int i = 0; i < 1024 * 10; i++) { + for (int i = 0; i < 1024 + 1; i++) { tokens.add(token("network", 1, 1)); } TokenStream ts = new CannedTokenStream(tokens.toArray(new Token[0])); GraphTokenStreamFiniteStrings graph = new GraphTokenStreamFiniteStrings(ts); - assertThrows(IllegalArgumentException.class, () -> graph.articulationPoints()); + assertThrows(IllegalArgumentException.class, graph::articulationPoints); } }