Repository navigation
Report string wrapping failures without crashing or hanging the CLI. - #1510
Merged
Merged
Conversation
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
Bot
force-pushed
the
test_1009611292
branch
from
October 29, 2026 13:22
7429c4a to
722d074
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Report string wrapping failures without crashing or hanging the CLI.
When reflowing long strings produced code that didn't parse,
StringWrapperpropagated javac's diagnostics, whose line numbers refer to the reflowed output.Mainthen printed them against the original input, andFormatterException.formatDiagnosticsthrewIndexOutOfBoundsExceptionif the error was past the input's last line. BecauseMain.formatFilesonly shut down its thread pool at the end, that exception also left non-daemon worker threads running, so the CLI hung instead of exiting.StringWrappernow reports an output that doesn't parse as an internal error, like the existing check for AST changes,formatDiagnosticsskips the source context for out-of-range positions, andMainshuts down its thread pool even if formatting throws.This is the crash reported in #1439.