Skip to content

Align empty input handling for statement parsing - #2594

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/parser-empty-input
Sep 11, 2026
Merged

Align empty input handling for statement parsing#2594
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:fix/parser-empty-input

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

Null and empty strings currently return null from the String parse and parseStatements overloads, even though blank and comment-only input already follows the single-statement versus statement-list contract. Make parse("") and parse((String) null) throw JSQLParserException, and make parseStatements return a fresh, mutable empty Statements list for either input.

Share single-statement input validation and remove the redundant guard in the default statement-list overload. Apply the contract to the configuration-callback and caller-executor overloads, preserving executor ownership. Document the intentional change from the previous null returns.

Regression coverage includes null, empty, blank and comment-only input with complex parsing enabled/disabled, Reader/InputStream consistency, caller-executor reuse after parsing, and independent mutable empty results.

Validation:

  • The new regression suite failed on the unchanged implementation (7 failures) and passes with the fix.
  • Full Gradle check, including formatting, static analysis and coverage: passed.
  • Maven clean verify: passed.

Fixes #2576.

Reject null and empty single-statement input with JSQLParserException and return independent empty statement lists from all String overloads. Add regression coverage and document the behavior change.

Fixes JSQLParser#2576.
@manticore-projects
manticore-projects merged commit 1bef513 into JSQLParser:master Sep 11, 2026
9 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you for this fine tuning! Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseStatements returns null instead of throwing JSQLParserException when withAllowComplexParsing(false) and the input does not parse

2 participants