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

[commons] CloseableServiceObjects needs to keep track of use count #119

Closed
kriegfrj opened this issue May 27, 2020 · 0 comments
Closed

[commons] CloseableServiceObjects needs to keep track of use count #119

kriegfrj opened this issue May 27, 2020 · 0 comments
Milestone

Comments

@kriegfrj
Copy link
Contributor

Was implementing #116 and wondering why my test kept failing - resources not getting cleaned up when expected. I think it's because I uncovered a real bug.

CloseableServiceObjects keeps track of services returned by getService() in an IdentityHashMap-backed set called instances. Then on close it iterates through them all and calls ungetService() to release them.

However, I discovered using the debugger that getService() internally increments the use count every time you call it, even if it returns the exact same service instance as a previous call. So really, you need to make sure that every getService() is paired with an ungetService(), and not simply call it once per service object.

Should be an easy fix (on its way).

kriegfrj added a commit to kriegfrj/osgi-test that referenced this issue Jun 3, 2020
Fixes osgi#119.

Signed-off-by: Fr Jeremy Krieg <fr.jkrieg@greekwelfaresa.org.au>
@bjhargrave bjhargrave added this to the 1.0.0 milestone Jun 4, 2021
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

No branches or pull requests

2 participants