#1249 Allow skip of individual SF_SWITCH_FALLTHROUGH


With the Checkstyle plugin you can use an inline comment to indicate that you mean for one case to fall through to the next. It would be great for FindBugs to honor the same comment.

However, that's my understanding is that since FindBugs processes the bytecode this isn't possible. Is there any other method that could work here?

Here's a ridiculous example demonstrating how it works with Checkstyle:

public boolean isSouth(Direction direction) {
    switch (direction) {
    case EAST: // fallthru
    case WEST: // fallthru
    case NORTH:
        return false;
    case SOUTH:
        return true;


  • David Harkness

    David Harkness - 2014-01-29

    Sorry, it's been some time since I used the SF.net issue tracker. I forgot that it separates bugs and feature requests. Is there a way to move this and the other request I created about ignoring warnings using "serial"?

  • William Pugh

    William Pugh - 2014-02-06

    First, the example you show for CheckStyle isn't a bug and FindBugs wouldn't complain about it. Having multiple case statements for one block of code isn't a fall trough.

    But as Andy mentioned, we will check this under the circumstance described. I guess the question is whether we should change that option to the default.

  • William Pugh

    William Pugh - 2014-02-06
    • assigned_to: William Pugh
  • David Harkness

    David Harkness - 2014-02-06

    Ah, I wasn't aware that it was only considered "fall-through" if the case wasn't empty. My apologies for a doubly-failed example. Here is the actual code where I see the FindBugs warning and use the Checkstyle comment:

    SystemPhase phase = shutdownService.shutdown();
    StringBuilder status = new StringBuilder();
    switch (phase) {
    case SHUTDOWN:
        status.insert(0, "done\n\nShutdown complete");
        // fallthru
    case JOB_QUEUE:
        status.insert(0, "done\n\nStopping thread pool...");
        // fallthru
    case SESSIONS:
        status.insert(0, "\n\nBlocking new sessions...");
        // fallthru
    case RUNNING:
        status.insert(0, "System shutdown initiated");
        // fallthru
    return status.toString();
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-19
    • Group: 3.0.0 --> 3.0.1
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-20
    • status: open --> closed-fixed
    • assigned_to: William Pugh --> Andrey Loskutov
    • Group: 3.x --> 3.0.0

Log in to post a comment.