pandaapo commented on PR #4145:
URL: https://github.com/apache/eventmesh/pull/4145#issuecomment-1609447685

   @lrhkobe Thank you for your review. 
   
   `Set` indeed stores `Session`'s reference. But it does not mean 
`Set<Session>#remove(Session)` can remove a stored `Session` successfully. 
Because `Session` overrides the `hashCode()` method, it results in the hash 
value of `Session` will be changed after it is stored in `Set`. Just like what 
I explain in https://github.com/apache/eventmesh/pull/4145#issue-1765742977
   >When `Session` is added to the `topic2sessionInGroupMapping`, a 
`java.util.Set`, `Session.sessionState` is `CREATED`. But session is almost 
impossible to keep this state. It will be `RUNNING` or `CLOSED`. So the hash of 
`Session` is changed. 
   
   `Set#remove` uses `Map#remove` to implement. `Map` use the hash value to 
find an element to remove. Because the hash value is changed after `Session` is 
put into `Map`'s bucket, `Map#remove` will failed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to