Skip to content
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

Fix race condition with disposal in MemberSingle.tryEmit #59

Merged
merged 2 commits into from Oct 10, 2021

Conversation

davidmoten
Copy link
Owner

@davidmoten davidmoten commented Oct 10, 2021

As reported in #58 there was a race condition where all Observers could be disposed by the time the code hits this line in MemberSingle.tryEmit:

if (x.index == index && x.observers[index] == o) {

If all observers have been disposed then x.observers[index] throws an ArrayIndexOutOfBoundsException.

The fix is to check the active count of observers.

I've also fixed the message of a Precondtions check, added some comments, and moved another comment to a better place.

@davidmoten davidmoten added the bug label Oct 10, 2021
@davidmoten davidmoten marked this pull request as draft October 10, 2021 04:44
@davidmoten davidmoten marked this pull request as ready for review October 10, 2021 04:45
@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2021

Codecov Report

Merging #59 (71e6af1) into master (21c91fb) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #59      +/-   ##
============================================
- Coverage     77.32%   77.28%   -0.04%     
  Complexity      669      669              
============================================
  Files            73       73              
  Lines          2747     2747              
  Branches        240      240              
============================================
- Hits           2124     2123       -1     
  Misses          517      517              
- Partials        106      107       +1     
Impacted Files Coverage Δ
...main/java/org/davidmoten/rx/pool/MemberSingle.java 90.18% <0.00%> (-0.37%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21c91fb...71e6af1. Read the comment docs.

@davidmoten davidmoten merged commit 8bac6ba into master Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants