Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Consistent formatting of multivariable try-with-resource blocks.

Open
#1,392 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
tooling

Research direction

No file or test is named in the issue. Start by reproducing the shown Java input and comparing the current formatter output with the requested multiline try-with-resources layout; done means consistent alignment with multiline parameters or code blocks without changing unrelated formatting.

Written by the indexing model from the issue text.

Description

The current formatting of try-with-resource blocks that manage multiple variables is strange, as it results in inconsistent alignment and doesn't match how multiline parameters or code blocks are formatted.

Current output:

try (var input = Files.newInputStream(Path.of("./input"));
    var output = Files.newOutputStream(Path.of("./output")); ) {
  output.write(input.read());
} catch (IOException _) {
}

How I think it should be formatted:

try (
  var input = Files.newInputStream(Path.of("./input"));
  var output = Files.newOutputStream(Path.of("./output"));
) {
  output.write(input.read());
} catch (IOException _) {
}
Dominant language
Java
Stars
6.2k
Forks
936
Avg merge
6m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/google-java-format

All issues in google/google-java-format

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.