-
Notifications
You must be signed in to change notification settings - Fork 72
Bugfix unregister activity #840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
symphony-enrico
merged 2 commits into
finos:main
from
symphony-enrico:bugfix/unregisterActivities
Oct 21, 2025
Merged
Bugfix unregister activity #840
symphony-enrico
merged 2 commits into
finos:main
from
symphony-enrico:bugfix/unregisterActivities
Oct 21, 2025
+225
−32
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
symphony-enrico
commented
Oct 21, 2025
symphony-bdk-core/src/main/java/com/symphony/bdk/core/activity/AbstractActivity.java
Outdated
Show resolved
Hide resolved
The ActivityRegistry is responsible for binding activities to a data feed. When an activity is registered, the system ensures that duplicates are not allowed. If an activity with the same identity is already registered, the old one is unregistered before the new one is added. A mechanism to explicitly unregister an activity was added in a previous PR, reusing the existing logic for handling duplicate registrations. However, both the original code and the previous PR did not always behave as expected. While this worked for Command activities, it failed for FormReplyActivity and UserJoinedRoomActivity. These activities create their listeners using lambdas, and each call produces a new lambda instance. In Java, even if two lambdas are created from the same code and the same activity instance, they are treated as different objects. Consequently, registering the same activity twice would generate a new listener object, preventing the system from detecting duplicates. The workaround is to modify listener generation: the activity that creates the listener is now encapsulated inside the listener itself, and equals() and hashCode() are implemented so that two listeners are considered equal if they originate from the same activity. This ensures that duplicate registrations are properly detected and handled.
554319c to
6536086
Compare
thibauult
approved these changes
Oct 21, 2025
Member
thibauult
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
symphony-enrico
added a commit
to symphony-enrico/symphony-bdk-java
that referenced
this pull request
Oct 22, 2025
* Bugfix unregister activity The ActivityRegistry is responsible for binding activities to a data feed. When an activity is registered, the system ensures that duplicates are not allowed. If an activity with the same identity is already registered, the old one is unregistered before the new one is added. A mechanism to explicitly unregister an activity was added in a previous PR, reusing the existing logic for handling duplicate registrations. However, both the original code and the previous PR did not always behave as expected. While this worked for Command activities, it failed for FormReplyActivity and UserJoinedRoomActivity. These activities create their listeners using lambdas, and each call produces a new lambda instance. In Java, even if two lambdas are created from the same code and the same activity instance, they are treated as different objects. Consequently, registering the same activity twice would generate a new listener object, preventing the system from detecting duplicates. The workaround is to modify listener generation: the activity that creates the listener is now encapsulated inside the listener itself, and equals() and hashCode() are implemented so that two listeners are considered equal if they originate from the same activity. This ensures that duplicate registrations are properly detected and handled. * Coverage improved
symphony-enrico
added a commit
that referenced
this pull request
Oct 22, 2025
* Bugfix unregister activity (#840) * Bugfix unregister activity The ActivityRegistry is responsible for binding activities to a data feed. When an activity is registered, the system ensures that duplicates are not allowed. If an activity with the same identity is already registered, the old one is unregistered before the new one is added. A mechanism to explicitly unregister an activity was added in a previous PR, reusing the existing logic for handling duplicate registrations. However, both the original code and the previous PR did not always behave as expected. While this worked for Command activities, it failed for FormReplyActivity and UserJoinedRoomActivity. These activities create their listeners using lambdas, and each call produces a new lambda instance. In Java, even if two lambdas are created from the same code and the same activity instance, they are treated as different objects. Consequently, registering the same activity twice would generate a new listener object, preventing the system from detecting duplicates. The workaround is to modify listener generation: the activity that creates the listener is now encapsulated inside the listener itself, and equals() and hashCode() are implemented so that two listeners are considered equal if they originate from the same activity. This ensures that duplicate registrations are properly detected and handled. * Coverage improved * Bugfix unregister activity (#840) * Bugfix unregister activity The ActivityRegistry is responsible for binding activities to a data feed. When an activity is registered, the system ensures that duplicates are not allowed. If an activity with the same identity is already registered, the old one is unregistered before the new one is added. A mechanism to explicitly unregister an activity was added in a previous PR, reusing the existing logic for handling duplicate registrations. However, both the original code and the previous PR did not always behave as expected. While this worked for Command activities, it failed for FormReplyActivity and UserJoinedRoomActivity. These activities create their listeners using lambdas, and each call produces a new lambda instance. In Java, even if two lambdas are created from the same code and the same activity instance, they are treated as different objects. Consequently, registering the same activity twice would generate a new listener object, preventing the system from detecting duplicates. The workaround is to modify listener generation: the activity that creates the listener is now encapsulated inside the listener itself, and equals() and hashCode() are implemented so that two listeners are considered equal if they originate from the same activity. This ensures that duplicate registrations are properly detected and handled. * Coverage improved * Release 3.2.6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ActivityRegistry is responsible for binding activities to a data feed. When an activity is registered, the system ensures that duplicates are not allowed. If an activity with the same identity is already registered, the old one is unregistered before the new one is added.
A mechanism to explicitly unregister an activity was added in a previous PR, reusing the existing logic for handling duplicate registrations. However, both the original code and the previous PR did not always behave as expected. While this worked for Command activities, it failed for FormReplyActivity and UserJoinedRoomActivity.
These activities create their listeners using lambdas, and each call produces a new lambda instance. In Java, even if two lambdas are created from the same code and the same activity instance, they are treated as different objects. Consequently, registering the same activity twice would generate a new listener object, preventing the system from detecting duplicates.
The workaround is to modify listener generation: the activity that creates the listener is now encapsulated inside the listener itself, and equals() and hashCode() are implemented so that two listeners are considered equal if they originate from the same activity. This ensures that duplicate registrations are properly detected and handled.