Avoid throwing StackOverflowError when creating RegExp [LUCENE-10474]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
Creating a regular expression using Lucene's RegExp class can easily result in a StackOverflowError being thrown, for example when the input is larger than the maximum stack depth. Throwing a StackOverflowError isn't something a user would expect, and it isn't documented either. StackOverflowError is a user-unfriendly exception as it does not convey any intent that the user has done something wrong, but suggests a bug in the implementation.
I would like Lucene to follow the [approach taken by the JDK](https://github.com/openjdk/jdk/blob/cab4ff64541393a974ea91e35167668ef0036804/src/java.base/share/classes/java/util/regex/Pattern.java#L1441) and throw an IllegalArgumentException instead to clearly mark this as an input that the implementation can't handle.
---
Migrated from [LUCENE-10474](https://issues.apache.org/jira/browse/LUCENE-10474) by Yannick Welsch (@ywelsch), updated Mar 21 2022
Pull requests: https://github.com/apache/lucene/pull/752, https://github.com/apache/lucene/pull/752
Contributor guide
Research direction
Start with Lucene's RegExp class and compare its handling of oversized regular expressions with the linked JDK Pattern.java approach. Done means inputs that currently cause StackOverflowError instead produce IllegalArgumentException, with the existing pull request and related tests checked for expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100