You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Report string-reflow failures cleanly instead of crashing the CLI #173
google-java-format#1510 (merged 2026-10-29, copybara export, fixing the crash from google-java-format#1439) covers the case where reflowing a long string literal yields code that no longer parses. javac's diagnostics then point at lines of the reflowed text, but the CLI printed them against the original input, and the diagnostic printer threw IndexOutOfBounds when the line was past the end of the input. The failure also left the worker thread pool running, so the process hung. Upstream now reports an unparsable reflow as an internal error, makes the diagnostic printer skip the source excerpt for out-of-range positions, and shuts the pool down in a finally block.
Why it matters: our StringWrapper.wrapOnce re-parses the reflowed result in the same way (it calls parse(result, ...) for the AST-equality check), so a bad reflow could surface javac diagnostics with output-relative line numbers. Our Main already uses try-with-resources for the executor (line ~127), so the hang part is probably not an issue; the diagnostic part needs checking.
the FormatterException diagnostic printing (locate its class; it is not in the java package directory)
Suggested action: investigate. Wrap the parse of the reflowed output so a failure becomes an "internal error, please report" FormatterException, and make the diagnostic printer tolerate out-of-range line numbers. Examples: not available - the item gives no input that triggers it.
Filed from an upstream-watch ticket after manual review.
The hang.Main.formatFiles closes its executor with try-with-resources, so a failure cannot leave the pool running.
The IndexOutOfBounds. Our CLI prints a diagnostic as path:line:column: error: message and never prints the source line, so it does no line lookup that could go out of range.
What is left is only theoretical. If a reflow ever produced code that does not parse, the file would fail with javac's message at a position in the reflowed text rather than in the input. Nothing broken would be written. I found no input that gets there; if one turns up, reopen this issue with it.
Activity
abashev commentedon Oct 30, 2026
Closing, because this does not reproduce here. I checked it on 21.X.X (6bcacfc).
\\t. That leaves an unterminated string literal. OurStringWrapperstopped splitting inside an escaped backslash in 53ac7d8 (A long string containing \\t fails to format: spurious "unclosed string literal" #32, from 2.89.0: spurious 'unclosed string literal' errors when file contains long strings (>~97 chars) in chained method calls palantir/palantir-java-format#1680). I ran upstream's input fromDiagnosticTest.stringWrappingProducesInvalidCodethrough the CLI here. It exits with 0 and keeps\\tendin one piece.Main.formatFilescloses its executor with try-with-resources, so a failure cannot leave the pool running.path:line:column: error: messageand never prints the source line, so it does no line lookup that could go out of range.What is left is only theoretical. If a reflow ever produced code that does not parse, the file would fail with javac's message at a position in the reflowed text rather than in the input. Nothing broken would be written. I found no input that gets there; if one turns up, reopen this issue with it.