An idempotent operation may produce a side effect, but repeating it produces the same result as applying it once. Assignment such as x = 0 is idempotent; x += 10 is not because each execution depends on the previous value. section 3.8
An idempotent loop body can leave the loop condition unchanged. If the condition starts true, the loop then runs forever; if it never repeats, the loop may be redundant and better expressed as an if statement. section 3.8
A unique-ID loop that never advances
makeUniqueId checks whether uniqueId is already used, but its loop body never changes uniqueId. Calling makeUniqueId("id", Set.of("id", "id_1")) therefore repeats the same check indefinitely instead of trying another candidate.
Prevent idempotent-loop mistakes by checking:
- Whether the body changes the state tested by the condition. section 3.8
- Whether a for-loop update statement advances toward termination. section 3.8
















