René's URL Explorer Experiment


Title: Do not inline a lambda body whose closing paren carries a comment by abashev · Pull Request #77 · openjavaformat/open-java-format · GitHub

Open Graph Title: Do not inline a lambda body whose closing paren carries a comment by abashev · Pull Request #77 · openjavaformat/open-java-format

X Title: Do not inline a lambda body whose closing paren carries a comment by abashev · Pull Request #77 · openjavaformat/open-java-format

Description: Closes #62, which mirrors palantir#1792 (the reporter also points at palantir#1152). The bug A // comment on its own line before the )) that close a lambda's parenthesized body and the call around it was joined onto the code line before it, and the )) ended up inside the comment: || items[i].getName().equals("gamma")// || (items[i].getName().equals("delta") && items.length > // i// && items[i + 1].getName().equals("epsilon")))) The output no longer parsed. The command line noticed only because its import pass parses the result again, and reported error: ')' expected at a position in the output; a caller of formatSource got the text as it was. Why An expression lambda's body is laid out by handle_breakOnlyIfInnerLevelsThenFitOnOneLine. When the body does not fit after -> but its first line does, tryInlinePrefixOntoCurrentLine lays the body's level out "on one line" through tryToLayOutLevelOnOneLine, which marks every break of that level as not taken and only lets the inner levels break. The comments before the closing ) belong to that same level, with forced breaks around them, and a forced break laid out flat is exactly what put the comment on the code line. The docs before the last inner level were checked for that (a forced break makes their width infinite); the docs after it were not checked at all. google-java-format has no such inlining, which is why it lays the input out correctly. The fix tryInlinePrefixOntoCurrentLine now refuses a level whose trailing docs have infinite width, the same check tryBreakInnerLevel already makes for its suffix. Such a body is not inlined and breaks normally: it starts on the line after ->, and the comments keep their own lines at the body's indent, which is what the formatter already did when the body's first line did not fit either: .filter(i -> (items[i].getName().equals("alpha") || items[i].getName().equals("beta") || items[i].getName().equals("gamma") // || (items[i].getName().equals("delta") && items.length > i // && items[i + 1].getName().equals("epsilon")) )) .findFirst() .orElse(-1); A block comment in the same place went through the same path: it came out glued to the code without a space, bbb(i)/* block */));, and moved on a second run. It gets its own line now as well. Checked The golden ojf-issue-62-comment-before-lambda-close-parens holds the reporter's input, the same shape as a plain call, and the block comment. It fails on main (--skip-* flags show the raw output) and passes with the change, and its output is stable on a second run. Related shapes format exactly as on main: a trailing // comment inside the body, a comment before the single ) of a call, a parenthesized argument that is not a lambda, a short body that already moved after ->, and a statement lambda with a comment before }. ./gradlew :open-java-format:test on JDK 21: 1541 tests, all green. The 15,747 files of the JDK 21 sources format exactly as before; none of them has a comment before )), and the five with a comment before a single ) do not change. Version Only input that failed today, or came out glued and unstable, formats differently, so this is a bug fix in the 2.x sense.

Open Graph Description: Closes #62, which mirrors palantir#1792 (the reporter also points at palantir#1152). The bug A // comment on its own line before the )) that close a lambda's parenthesized body and the call aro...

X Description: Closes #62, which mirrors palantir#1792 (the reporter also points at palantir#1152). The bug A // comment on its own line before the )) that close a lambda's parenthesized body and the call...

Opengraph URL: https://github.com/openjavaformat/open-java-format/pull/77

X: @github

direct link

Domain: redirect.github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e2f90db4-1db8-8c73-099f-77ad328f542b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id92B2:363B1C:5B906:78566:6AFBD90F
html-safe-nonce3c0518c985d1848f6dc05db09096d7d14e65bc77626e016348d5ab4a1f1440ec
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkIyOjM2M0IxQzo1QjkwNjo3ODU2Njo2QUZCRDkwRiIsInZpc2l0b3JfaWQiOiI3NDgzMTExNTE0MzQxODkwMzE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7f766cd983b0b4b3d224ed09de03f344c4a24804668b69e78fa20b695a5291f0
hovercard-subject-tagpull_request:4635987775
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/openjavaformat/open-java-format/pull/77/files
twitter:imagehttps://avatars.githubusercontent.com/u/214171?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/214171?s=400&v=4
og:image:altCloses #62, which mirrors palantir#1792 (the reporter also points at palantir#1152). The bug A // comment on its own line before the )) that close a lambda's parenthesized body and the call aro...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None18742cb872ec73544356e60359266b67aafece70c4ce008042e06227924cdd07
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git
octolytics-dimension-user_id325177626
octolytics-dimension-user_loginopenjavaformat
octolytics-dimension-repository_id1288055459
octolytics-dimension-repository_nwoopenjavaformat/open-java-format
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forktrue
octolytics-dimension-repository_parent_id214273098
octolytics-dimension-repository_parent_nwopalantir/palantir-java-format
octolytics-dimension-repository_network_root_id214273098
octolytics-dimension-repository_network_root_nwopalantir/palantir-java-format
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release820be804f18e1ef3940bd74a00d41d73d02e2b91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fpull%2F77%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fpull%2F77%2Ffiles
Sign uphttps://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=openjavaformat%2Fopen-java-format
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Reloadhttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
openjavaformathttps://redirect.github.com/openjavaformat
open-java-formathttps://redirect.github.com/openjavaformat/open-java-format
Codehttps://redirect.github.com/openjavaformat/open-java-format
Issues30 (30)https://redirect.github.com/openjavaformat/open-java-format/issues
Pull requests5 (5)https://redirect.github.com/openjavaformat/open-java-format/pulls
Discussionshttps://redirect.github.com/openjavaformat/open-java-format/discussions
Actionshttps://redirect.github.com/openjavaformat/open-java-format/actions
Security and qualityhttps://redirect.github.com/openjavaformat/open-java-format/security
Insightshttps://redirect.github.com/openjavaformat/open-java-format/pulse
Sign up for GitHub https://redirect.github.com/signup?return_to=%2Fopenjavaformat%2Fopen-java-format%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://redirect.github.com/login?return_to=%2Fopenjavaformat%2Fopen-java-format%2Fissues%2Fnew%2Fchoose
abashevhttps://redirect.github.com/abashev
mainhttps://redirect.github.com/openjavaformat/open-java-format/tree/main
comment-before-lambda-close-parenshttps://redirect.github.com/openjavaformat/open-java-format/tree/comment-before-lambda-close-parens
Conversation 0 https://redirect.github.com/openjavaformat/open-java-format/pull/77
Commits 1 https://redirect.github.com/openjavaformat/open-java-format/pull/77/commits
Checks 15 https://redirect.github.com/openjavaformat/open-java-format/pull/77/checks
Files changed https://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Do not inline a lambda body whose closing paren carries a comment https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#top
Show all changes 1 commit https://redirect.github.com/openjavaformat/open-java-format/pull/77/files
bf9e0eb Do not inline a lambda body whose closing paren carries a comment abashev Sep 25, 2026 https://redirect.github.com/openjavaformat/open-java-format/pull/77/commits/bf9e0ebb5e1747527f094f8593a9e0fa91a5ffa9
Clear filters https://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
Level.java https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
ojf-issue-62-comment-before-lambda-close-parens.input https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-79629942735c573886dcc9c6440ddff75dc22e91dc8203d2d455437e61bdd67c
ojf-issue-62-comment-before-lambda-close-parens.output https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-42d2f6010de4d050222721ed7cc55c566b1bdb636eb6b16ec33766649096be1d
open-java-format/src/main/java/com/palantir/javaformat/doc/Level.javahttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
View file https://redirect.github.com/openjavaformat/open-java-format/blob/bf9e0ebb5e1747527f094f8593a9e0fa91a5ffa9/open-java-format/src/main/java/com/palantir/javaformat/doc/Level.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/77/{{ revealButtonHref }}
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689201?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689438?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689590?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689515?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004428/job/108003688908?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645470?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645398?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645455?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645509?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689201?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689438?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689590?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689515?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004428/job/108003688908?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645470?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645398?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645455?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645509?pr=77
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689201?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689438?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689590?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689515?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004428/job/108003688908?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645470?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645398?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645455?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645509?pr=77
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689201?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689438?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689590?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689515?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004428/job/108003688908?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645470?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645398?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645455?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645509?pr=77
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689201?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689438?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689590?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108003689515?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004428/job/108003688908?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645470?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645398?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645455?pr=77
https://redirect.github.com/openjavaformat/open-java-format/actions/runs/36114004410/job/108004645509?pr=77
https://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-fa5e6dffd4fb7354b4706d7c0d77bcaa3de70917d0983a2c8ed1c575eed87611
...m/palantir/javaformat/java/testdata/ojf-issue-62-comment-before-lambda-close-parens.inputhttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-79629942735c573886dcc9c6440ddff75dc22e91dc8203d2d455437e61bdd67c
View file https://redirect.github.com/openjavaformat/open-java-format/blob/bf9e0ebb5e1747527f094f8593a9e0fa91a5ffa9/open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/ojf-issue-62-comment-before-lambda-close-parens.input
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/77/{{ revealButtonHref }}
.../palantir/javaformat/java/testdata/ojf-issue-62-comment-before-lambda-close-parens.outputhttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files#diff-42d2f6010de4d050222721ed7cc55c566b1bdb636eb6b16ec33766649096be1d
View file https://redirect.github.com/openjavaformat/open-java-format/blob/bf9e0ebb5e1747527f094f8593a9e0fa91a5ffa9/open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/ojf-issue-62-comment-before-lambda-close-parens.output
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://redirect.github.com/openjavaformat/open-java-format/pull/77/{{ revealButtonHref }}
Please reload this pagehttps://redirect.github.com/openjavaformat/open-java-format/pull/77/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.