-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Milestone
Description
Hi,
I found the suspicious code via the PVS-Studio analyzer.
Here is the code:
...
case ShardId shardId:
_shards.Add(shardId); // <=
return true;
case SnapshotOffer offer when (offer.Snapshot is ShardCoordinator.CoordinatorState state):
_shards.UnionWith(state.Shards.Keys.Union(state.UnallocatedShards)); // <=
return true;
case SnapshotOffer offer when (offer.Snapshot is State state):
_shards.Union(state.Shards); // <=
...
Here is the link to the sources.
Several methods were called for the _shards
variable. The last invocation looks suspicious.
Add
and UnionWith
are methods of the HashSet<T>
type. They change the _shards
object state. But Union
is the extension method which does not change the _shards
state. The result of this invocation is not used as well.