Title: Join `"a " + "b"` string concatenations that end up on one line · Issue #148 · openjavaformat/open-java-format · GitHub
Open Graph Title: Join `"a " + "b"` string concatenations that end up on one line · Issue #148 · openjavaformat/open-java-format
X Title: Join `"a " + "b"` string concatenations that end up on one line · Issue #148 · openjavaformat/open-java-format
Description: Upstream: palantir#1781 Kind: bug | Priority: low palantir-java-format#1781 (closed unmerged on 2026-10-17) describes a leftover of string wrapping: when a long concatenation of literals is re-wrapped and the pieces end up on the same li...
Open Graph Description: Upstream: palantir#1781 Kind: bug | Priority: low palantir-java-format#1781 (closed unmerged on 2026-10-17) describes a leftover of string wrapping: when a long concatenation of literals is re-wrap...
X Description: Upstream: palantir#1781 Kind: bug | Priority: low palantir-java-format#1781 (closed unmerged on 2026-10-17) describes a leftover of string wrapping: when a long concatenation of literals is re-wrap...
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/148
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Join `\"a \" + \"b\"` string concatenations that end up on one line","articleBody":"**Upstream:** https://github.com/palantir/palantir-java-format/pull/1781 \n**Kind:** bug | **Priority:** low\n\n[palantir-java-format#1781](https://github.com/palantir/palantir-java-format/pull/1781) (closed unmerged on 2026-10-17) describes a leftover of string wrapping: when a long concatenation of literals is re-wrapped and the pieces end up on the same line, the `+` between two adjacent literals stays, because the string-wrapping pass only acts on lines that exceed the column limit. The PR adds a pass that merges runs of adjacent literals which already share a line into one literal, guarded so that it never merges across a comment (NON-NLS markers), never touches text blocks, and refuses merges that would change an octal escape such as `\"\\1\" + \"2\"`.\n\nWhy it matters to us: our `StringWrapper` has no such joining pass, so we should leave the same `\"...\" + \"...\"` residue and the formatting stays dependent on how the author wrapped the string. It also interacts with our open work on NON-NLS markers (our #23). The idea also changes the semantics-adjacent text of string literals, so the escape guard is the part to get right.\n\nAffected files: `open-java-format/src/main/java/com/palantir/javaformat/java/StringWrapper.java` (including the fast-path checks that decide whether wrapping is needed).\n\n**Before** (upstream behaviour before the change; our StringWrapper has no joining pass, not run):\n```java\nthrow new SafeIllegalArgumentException(\n \"Invalid recipient field - contains multiple \" + \"foreign key properties.\",\n UnsafeArg.of(\"field\", maybeField));\n```\n**After** (with the change):\n```java\nthrow new SafeIllegalArgumentException(\n \"Invalid recipient field - contains multiple foreign key properties.\",\n UnsafeArg.of(\"field\", maybeField));\n```\n\nSuggested action: investigate; adopt the idea only with the escape and comment guards, low priority.\n\n---\n_Filed from an upstream-watch ticket after manual review._","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-10-23T21:46:11Z","url":"https://github.com/openjavaformat/open-java-format/issues/148"}
| 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:9832234a-93fd-3027-64da-16681a42d7d8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A2E:1B1794:61142C:803B9B:6AFBC740 |
| html-safe-nonce | 6bcfe295ec9099d9b1db7c8a4e595b9f0b6f5a5ff196da9ed5958bd655c362f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTJFOjFCMTc5NDo2MTE0MkM6ODAzQjlCOjZBRkJDNzQwIiwidmlzaXRvcl9pZCI6IjU1MTc1ODI5MzYwNjYyMTM2OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f5eaa5d2fa56ee77ce0c35e92e6317627cf34d55c37be7762250454aff98296f |
| hovercard-subject-tag | issue:6005924859 |
| 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/148/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5f8056cbe1095da2a27d4f024e6dd5e843a73ebf6178645839e8e1181e7b393/openjavaformat/open-java-format/issues/148 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5f8056cbe1095da2a27d4f024e6dd5e843a73ebf6178645839e8e1181e7b393/openjavaformat/open-java-format/issues/148 |
| og:image:alt | Upstream: palantir#1781 Kind: bug | Priority: low palantir-java-format#1781 (closed unmerged on 2026-10-17) describes a leftover of string wrapping: when a long concatenation of literals is re-wrap... |
| 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 | d440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b |
| 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 | 2c43021aed8695990c86c0eaaedc600bfeffec36 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width