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

regression of issue #1008 on idea-plugin

Open
#1,271 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

No repository file or test is named. Start by reproducing the Java 21 switch example with idea-plugin 1.27.0 and compare its formatting with the CLI; done when the plugin handles case null, default consistently with the CLI without requiring the workaround.

Written by the indexing model from the issue text.

Description

IntelliJ

Previously, when Issue #1008 was reported, it was resolved.

However, with the recent update to the idea-plugin to version 1.27.0, this issue resurfaced.

This piece of code:

switch (value) {
      case 0 -> "it was 0";
      case 1 -> "it was 1";
      case 2 -> "it was 2";
      case null, default -> "unexpected value";
    };

Works fine with the CLI version of google-java-formatter, but will fail for the idea-plugin version of google-java-formatter.

The only solution is to revert the above switch pattern into

      case null -> "null value";
      default -> "unexpected value";

A simple class to allow easy testing of this

public class Test {
    public static void main(String[] args) {
        Object obj = null; // or some other object
        String result = switch (obj) {
            case null, default -> "handled";
        };
        System.out.println(result);
    }
}

JDK Used: https://adoptium.net/en-GB/temurin/releases/?version=21

Dominant language
Java
Stars
6.2k
Forks
936
Avg merge
6m
Merged PRs (30d)
5

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.