Command line: quoted argfile paths, a closed thread pool, and the right flag in the --dry-run error - #45
Closed
abashev wants to merge 3 commits into
Closed
Command line: quoted argfile paths, a closed thread pool, and the right flag in the --dry-run error#45abashev wants to merge 3 commits into
abashev wants to merge 3 commits into
Conversation
…cludes itself CommandLineOptionsParser split an @argfile at every whitespace character and knew no quotes, so a path with a space in it became several arguments. Each was reported as "Skipping non-Java file", and the run still exited 0 (#40, from google/google-java-format#421). A parameter file that included itself recursed until the stack overflowed. This ports google/google-java-format#931 by Karlheinz Friedberger, its three commits squashed into one. An argument in a parameter file may be quoted with double or single quotes and then keeps its whitespace; an unclosed quote runs to the end of the file; and a file that is already being read is reported as "parameter file was included recursively". Escaped quotes are not handled, as upstream. The three CommandLineOptionsParserTest cases come from that PR.
Main.formatFiles created a fixed thread pool on every call and never shut it down. The command line does not notice, because the process exits, but a tool that runs Main in-process kept up to MAX_THREADS idle threads per call (#40, from google/google-java-format#384). The pool is now closed when formatFiles returns. On Java 21 ExecutorService is AutoCloseable, and close() waits for the submitted tasks, which formatFiles has already waited for by then. The new MainTest runs format from a thread of its own thread group, which the pool's threads join, and fails without the change because a pool thread is still running.
"cannot use --dry-run and --in-place at the same time" named a flag that does not exist: in-place formatting is -i, -r, -replace or --replace (#40, from google/google-java-format#1094). The message now says --replace, the long form the usage text shows. This ports google/google-java-format#1451 by rootkiller6788, including its test for the --replace --dry-run spelling next to -i -n.
abashev
enabled auto-merge
September 23, 2026 07:47
This was referenced Sep 23, 2026
Collaborator
Author
Collaborator
Author
|
Correction: main was reset, and the argfile quoting change is now #49. |
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.
Closes #40. Upstream reports: google/google-java-format#421, google/google-java-format#384, google/google-java-format#1094.
Three command-line fixes, one commit each. Two are ported from open upstream PRs and keep their authors.
From upstream, with the authors kept
@argfilemay be quoted with double or single quotes and then keeps its whitespace, so a path with a space in it is one path. Before, it became several arguments, each "Skipping non-Java file", and the run exited 0. A parameter file that includes itself is now reported as "parameter file was included recursively" instead of overflowing the stack. Escaped quotes are not handled, as upstream.--dry-runwith in-place formatting names--replace; before, it named--in-place, which does not exist.Added here
Main.formatFilesreturns. The command line did not notice the leak, because it exits, but a tool that runsMainin-process kept up toMAX_THREADSidle threads per call. On Java 21ExecutorServiceisAutoCloseable, andclose()waits for the submitted tasks, which have all been waited for by then.Checked
MainTest.formatLeavesNoPoolThreadRunningfails with "pool-1-thread-1 is still running";CommandLineFlagsTest.inPlaceDryRunfails on the old message../gradlew :open-java-format:teston JDK 21: 1421 tests, all green.--dry-run --replacenames--replace.