Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move max recursion from Operations.java to AutomatonTestUtil.java #12298

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ public final class Operations {
*/
public static final int DEFAULT_DETERMINIZE_WORK_LIMIT = 10000;

/** Maximum level of recursion allowed in recursive operations. */
public static final int MAX_RECURSION_LEVEL = 1000;

private Operations() {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class AutomatonTestUtil {
/** Default maximum number of states that {@link Operations#determinize} should create. */
public static final int DEFAULT_MAX_DETERMINIZED_STATES = 1000000;

/** Maximum level of recursion allowed in recursive operations. */
public static final int MAX_RECURSION_LEVEL = 1000;

/** Returns random string, including full unicode range. */
public static String randomRegexp(Random r) {
while (true) {
Expand Down Expand Up @@ -483,7 +486,7 @@ public static boolean isFinite(Automaton a) {
// large automata could exceed java's stack so the maximum level of recursion is bounded to 1000
private static boolean isFinite(
Transition scratch, Automaton a, int state, BitSet path, BitSet visited, int level) {
if (level > Operations.MAX_RECURSION_LEVEL) {
if (level > MAX_RECURSION_LEVEL) {
throw new IllegalArgumentException("input automaton is too large: " + level);
}
path.set(state);
Expand Down