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

removeStickyEvent(...) does not remove event the first time. #15

Closed
onyxmueller opened this issue Jan 4, 2013 · 8 comments
Closed

removeStickyEvent(...) does not remove event the first time. #15

onyxmueller opened this issue Jan 4, 2013 · 8 comments
Labels
bug Something isn't working

Comments

@onyxmueller
Copy link

I'm noticing a behavior where [EventBus.getDefault()].removeStickyEvent(...) does not remove the event immediately, but follow-up calls do. This occurs with both usages (event instance and class type). Is this a bug? Or is there a scenario where this can occur that I am not understanding?

@doridori
Copy link

doridori commented Jan 7, 2013

I heard a colleague complaining of this also but I didn't have time to look into it myself

@pmecho
Copy link

pmecho commented Feb 8, 2013

I'm seeing the same behavior, particularly after a configuration change. The onEvent callback removes the sticky event but the callback gets called an additional time after the configuration change. After that, it appears that the sticky event is removed and all is well.

@pmecho
Copy link

pmecho commented Feb 9, 2013

This is due to the event being posted before it is added to the sticky event map:

public void postSticky(Object event) {
    post(event);
    synchronized (stickyEvents) {
        stickyEvents.put(event.getClass(), event);
    }
}

I guess this is a drawback of sticky events and we should be looking for consumable events as was hinted at for a future release.

@doridori
Copy link

Couldnt these just be flipped round?

@greenrobot
Copy link
Owner

Posting after putting the event ("flipping around") makes sense to me. I'll make the change and think about a unit test for this scenario.

@doridori
Copy link

Cool thanks :) Is there any way to unit test async methods without using a timeout? I wrote a helper class for this but I imagine there is a better way. Dont worry if you are too busy to answer this as I will look up but interested to hear your approach.

@onyxmueller
Copy link
Author

This sounds like it should do the trick. Please let me know when the changes have been implemented and I will test to confirm it works as well. Thanks.

@greenrobot
Copy link
Owner

Fixed in 16ba793 with unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants