Skip to content

[4.9.4] SF_SWITCH_FALLTHROUGH false positive #3617

Description

@ben-manes

Upgrading from 4.9.3 and the rule misinterprets a continue as a fall-through scenario.

Image

The method scheduleAfterWrite() has a continue on the PROCESSING_TO_IDLE case,

/**
 * Conditionally schedules the asynchronous maintenance task after a write operation. If the
 * task status was IDLE or REQUIRED then the maintenance task is scheduled immediately. If it
 * is already processing then it is set to transition to REQUIRED upon completion so that a new
 * execution is triggered by the next operation.
 */
void scheduleAfterWrite() {
  @Var int drainStatus = drainStatusOpaque();
  for (;;) {
    switch (drainStatus) {
      case IDLE:
        casDrainStatus(IDLE, REQUIRED);
        scheduleDrainBuffers();
        return;
      case REQUIRED:
        scheduleDrainBuffers();
        return;
      case PROCESSING_TO_IDLE:
        if (casDrainStatus(PROCESSING_TO_IDLE, PROCESSING_TO_REQUIRED)) {
          return;
        }
        drainStatus = drainStatusAcquire();
        continue;
      case PROCESSING_TO_REQUIRED:
        return;
      default:
        throw new IllegalStateException("Invalid drain status: " + drainStatus);
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions