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

[Enhancement] SyncStateInfo defensive-copy and epoch semantics lack direct tests

Open Beginner friendly
#11,338 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@chennaji9 is already working on this.

Since Oct 9, 2026.

  • #11347 by @chennaji9 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
testing-qa

Research direction

The class under test is controller/src/main/java/org/apache/rocketmq/controller/impl/manager/SyncStateInfo.java, which copies sets on input in updateSyncStateSetInfo and on output in getSyncStateSet. Read those methods and the existing manager-level tests to see how the controller state is built. Add direct unit tests that mutate the caller's set and the returned set and assert the stored state is unchanged, that updateMasterInfo increments the master epoch, and that removeFromSyncState leaves the sync-state epoch alone. Done when the new tests pass and would fail if the copies were removed.

Written by the indexing model from the issue text.

Description

Description

SyncStateInfo (controller/src/main/java/org/apache/rocketmq/controller/impl/manager/SyncStateInfo.java) maintains the controller's per-broker view of mastership: master identity + epoch, and the sync-state set + epoch. It deliberately copies sets on the way in and out:

public void updateSyncStateSetInfo(Set<Long> newSyncStateSet) {
    this.syncStateSet = new HashSet<>(newSyncStateSet);
    ...
}
public Set<Long> getSyncStateSet() {
    return new HashSet<>(syncStateSet);
}

The existing manager-level tests touch the class via larger flows, but no test pins the defensive-copy contract itself: mutating the caller's set after updateSyncStateSetInfo (or mutating the set returned by the getter) must not corrupt controller state, updateMasterInfo must bump the master epoch, and removeFromSyncState must remove locally without advancing the sync-state epoch. Losing any of these (e.g. "simplifying" away the copies) would silently let callers mutate controller state and currently no test would notice.

Expected behavior

Direct unit coverage of the isolation and epoch semantics described above.

Dominant language
Java
Stars
22.6k
Forks
12k
Avg merge
6d 16h
Merged PRs (30d)
18

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 apache/rocketmq

All issues in apache/rocketmq

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.