Skip to content

Fix ValidateCounterId so an ID exactly equal to MaxCounterId also fails#143

Draft
strangelydim wants to merge 1 commit intomasterfrom
ebowden/agrona-counters-validate-counter-id
Draft

Fix ValidateCounterId so an ID exactly equal to MaxCounterId also fails#143
strangelydim wants to merge 1 commit intomasterfrom
ebowden/agrona-counters-validate-counter-id

Conversation

@strangelydim
Copy link
Copy Markdown

NOTE: This PR being created as a draft for discussion.

Java's maxCounterId is set to:

this.maxCounterId = (valuesBuffer.capacity() / COUNTER_LENGTH) - 1;

whereas .NET's is:

MaxCounterId = valuesBuffer.Capacity / COUNTER_LENGTH;

The better fix, IMO, is to change .NET to match Java, so "max counter ID" really is the max counter ID, not one higher than the max ID.

However, it's a public value, and users might already have code that uses it, so that would be a potentially breaking change.

The change in this PR is the simpler, non-breaking thing we could do. Which do we prefer?

@strangelydim strangelydim requested a review from JPWatson May 1, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant