Skip to content

Report string wrapping failures without crashing or hanging the CLI. - #1510

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1009611292
Oct 29, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1009611292

Conversation

@copybara-service

Copy link
Copy Markdown

Report string wrapping failures without crashing or hanging the CLI.

When reflowing long strings produced code that didn't parse, StringWrapper propagated javac's diagnostics, whose line numbers refer to the reflowed output. Main then printed them against the original input, and FormatterException.formatDiagnostics threw IndexOutOfBoundsException if the error was past the input's last line. Because Main.formatFiles only shut down its thread pool at the end, that exception also left non-daemon worker threads running, so the CLI hung instead of exiting.

StringWrapper now reports an output that doesn't parse as an internal error, like the existing check for AST changes, formatDiagnostics skips the source context for out-of-range positions, and Main shuts down its thread pool even if formatting throws.

This is the crash reported in #1439.

When reflowing long strings produced code that didn't parse, `StringWrapper` propagated javac's diagnostics, whose line numbers refer to the reflowed output. `Main` then printed them against the original input, and `FormatterException.formatDiagnostics` threw `IndexOutOfBoundsException` if the error was past the input's last line. Because `Main.formatFiles` only shut down its thread pool at the end, that exception also left non-daemon worker threads running, so the CLI hung instead of exiting.

`StringWrapper` now reports an output that doesn't parse as an internal error, like the existing check for AST changes, `formatDiagnostics` skips the source context for out-of-range positions, and `Main` shuts down its thread pool even if formatting throws.

This is the crash reported in #1439.

PiperOrigin-RevId: 1009639357
@copybara-service
copybara-service Bot merged commit 722d074 into master Oct 29, 2026
4 checks passed
@copybara-service
copybara-service Bot deleted the test_1009611292 branch October 29, 2026 13:23
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.

1 participant