Title: Format a single file on the calling thread, without a thread pool · Issue #227 · openjavaformat/open-java-format · GitHub
Open Graph Title: Format a single file on the calling thread, without a thread pool · Issue #227 · openjavaformat/open-java-format
X Title: Format a single file on the calling thread, without a thread pool · Issue #227 · openjavaformat/open-java-format
Description: What happens Main.formatFiles creates a fixed pool of min(20, files) threads whatever the number of files, so a single file is read on the main thread, formatted on a pool thread and taken back with Future.get. Standard input already for...
Open Graph Description: What happens Main.formatFiles creates a fixed pool of min(20, files) threads whatever the number of files, so a single file is read on the main thread, formatted on a pool thread and taken back wit...
X Description: What happens Main.formatFiles creates a fixed pool of min(20, files) threads whatever the number of files, so a single file is read on the main thread, formatted on a pool thread and taken back wit...
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/227
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Format a single file on the calling thread, without a thread pool","articleBody":"### What happens\n\n`Main.formatFiles` creates a fixed pool of `min(20, files)` threads whatever the number of files, so a single file is read on the main thread, formatted on a pool thread and taken back with `Future.get`. Standard input already formats on the calling thread: `formatStdin` calls `FormatFileCallable.call()` directly.\n\nOne file on the command line is the common case: the pre-commit hook and the GitHub Action run the native binary once for each file, as `--dry-run --set-exit-if-changed \"$FILE\"`, and code that runs `Main` in process creates and closes a pool on every call.\n\n### What the pool costs\n\nLittle. The 21.0.2 native binary on `java/util/ArrayList.java` of JDK 21, median of 30 runs: 111.0 ms with the file as an argument, 110.6 ms with it on standard input. The gain is one code path less and no thread to start and stop, not time.\n\n### Proposal\n\nWith one Java file left after the others are skipped, format it on the calling thread, as `formatStdin` does, and report its errors as the pooled path does: the diagnostics of a `FormatterException`, the message and stack trace of any other exception.\n\n### google-java-format\n\nThe same: `formatFiles` creates `min(MAX_THREADS, files)` threads for one file too.\n","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-11-13T21:41:04Z","url":"https://github.com/openjavaformat/open-java-format/issues/227"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3cfe799f-a5fc-a7c7-5533-df0314458e76 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A4E:116DB0:9573F:CE5F2:6AFBB793 |
| html-safe-nonce | 4d6400a92bc14012c11ac33acbccfd0cd1512829ef5fa24ec804ff5d49de39b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTRFOjExNkRCMDo5NTczRjpDRTVGMjo2QUZCQjc5MyIsInZpc2l0b3JfaWQiOiI4NzMzOTY5ODk1NDc5MDMxNjk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 08f581724ebe09108d3b2faa04201f8549ee1e3331a081f5565be1cd55e2648b |
| hovercard-subject-tag | issue:6380462416 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openjavaformat/open-java-format/227/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1d6aa642ed1f91ce9e4510a818324e0764ab68be6c5527698abcb09f8a10c36/openjavaformat/open-java-format/issues/227 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1d6aa642ed1f91ce9e4510a818324e0764ab68be6c5527698abcb09f8a10c36/openjavaformat/open-java-format/issues/227 |
| og:image:alt | What happens Main.formatFiles creates a fixed pool of min(20, files) threads whatever the number of files, so a single file is read on the main thread, formatted on a pool thread and taken back wit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abashev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c |
| turbo-cache-control | no-preview |
| go-import | github.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git |
| octolytics-dimension-user_id | 325177626 |
| octolytics-dimension-user_login | openjavaformat |
| octolytics-dimension-repository_id | 1288055459 |
| octolytics-dimension-repository_nwo | openjavaformat/open-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 214273098 |
| octolytics-dimension-repository_parent_nwo | palantir/palantir-java-format |
| octolytics-dimension-repository_network_root_id | 214273098 |
| octolytics-dimension-repository_network_root_nwo | palantir/palantir-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e4cce0e99cf61481a318ff12c2e8580153a6c7c6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width