# Hazelcast — Diamond Recursion (CWE-407 O(2^D)) Scan: CLEAN

**Pattern:** Recursive cycle-detection / dependency traversal without a visited set
(exponential re-visitation on diamond-shaped DAGs)
**Scan date:** 2026-03-29
**Scope:** `hazelcast/src/main/java/` — partition management, Jet DAG, service manager, SQL

## Methods Checked

| Method | Location | Guard | Result |
|--------|----------|-------|--------|
| `isCyclic(PartitionReplica[], PartitionReplica[], int)` | `MigrationPlanner.java:369` | Iterative loop with index tracking (no recursion) | CLEAN |
| `TopologicalSorter.strongConnect` | `TopologicalSorter.java` | Tarjan's algorithm — `tv.index != -1` visited guard | CLEAN |
| `checkTopologicalSort` | `TopologicalSorter.java` | `Set<V> seen` | CLEAN |
| `ServiceManagerImpl` service ordering | `ServiceManagerImpl.java` | No recursive dependency traversal found | CLEAN |

## Conclusion

Hazelcast Jet uses a proper Tarjan strongly-connected-components algorithm for cycle detection
in its DAG processor. The `MigrationPlanner.isCyclic` uses an iterative while-loop (not
recursive). No diamond-recursion pattern was found.
