Skip to content

fix: addProvider threw UnsupportedOperationException on the provider register events - #94

Merged
Phoenix-Ra merged 3 commits into
VisorModStudio:devfrom
LPlusBonk:fix/provider-event-immutable-list
Oct 14, 2026
Merged

Phoenix-Ra merged 3 commits into
VisorModStudio:devfrom
LPlusBonk:fix/provider-event-immutable-list

Conversation

@LPlusBonk

Copy link
Copy Markdown
Contributor

The four "Register...VREvent" classes in
visor-api/src/main/java/org/vmstudio/visor/api/client/events/provider/ kept the list passed into their constructors as just a List. XrInputHandler passes List.of(...), an immutable List, into those constructors, so calling providers.add(...) in the addProvider methods would throw UnsupportedOperationException and the event bus would log it but swallow it. The fix done here is to copy the list into an ArrayList in each constructor, but a deeper fix could be to change the private final List providers; to ArrayList, but that would technically change the API surface so I opted not to.

The four "Register...VREvent" classes in
visor-api/src/main/java/org/vmstudio/visor/api/client/events/provider/ kept the list passed into their
constructors as just a List. XrInputHandler passes List.of(...), an
immutable List, into those constructors, so calling providers.add(...) in the addProvider methods would
throw UnsupportedOperationException and the event bus would log it but swallow it. The fix done here is to copy the list into an ArrayList in each constructor, but a deeper fix could be to change the private final List<XRBodyHapticsProvider> providers; to ArrayList, but that would technically change the API surface so I opted not to.
…an ArrayList

This just increases the robustness of the change, enforcing that any future methods that may be created, especially accessors, cannot possibly return or access or especially set the <code>providers</code> member to an immutable <code>List</code> implementation.

@LPlusBonk LPlusBonk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, looks like what I wrote 👍

…o store an ArrayList"

This reverts commit 021a5fd. Because of
the @Getter annotation, changing the underlying member's type affected
the API surface, which is unnecessary considering this is a band-aid fix
to this mutable-immutable list abstraction issue to be addressed in
0.7.0.
@Phoenix-Ra
Phoenix-Ra merged commit 5f8f154 into VisorModStudio:dev Oct 14, 2026
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.

2 participants