Wait for running threads on XmppSession.close()
When calling the .close()
method on a XmppSession
, while another thread, that uses the XmppSession
, is running (e.g. PresenceListeners) the running threads throw IllegalStateException
s, because the XmppSession
was closed.
This is very inconvenient. Especially if your main thread doesn't run long enough for letting the other threads process the batch of presence changes after the login.
I would expect the .close()
method to wait for the running threads to terminate and only then close the connection (or optionally take a timeout after which the connection is closed, thus crashing the running threads).
Comments (7)
-
repo owner -
reporter I tried to reproduce this accurately. It turns out that I can't reproduce what I observed some weeks ago. I noticed that the "Avatar Request Thread" throws an exception in the attached reproduction program, but that's not what I observed and doesn't seem to cause any harm. I also noticed that the listener threads don't terminate with an exception, but rather seem to be daemon threads and just terminate as soon as the main thread dies. I guess this is a feature rather than a bug.
-
repo owner Yes, the listener threads are daemon threads (by design). I can't find any "reproduction program", where do you have it?
-
reporter - attached Reproduce.java
Porgram for reproducing the exception thrown.
-
repo owner Thanks, I could reproduce the issue. Coincidentally I was just about to release 0.5.1 and I've fixed this bug as well. So you could try it out. Maybe the fix is not the best solution, but good enough for the 0.5 branch.
-
repo owner - changed status to resolved
Dispose Managers when closing the session has started, not after it's closed.
This allows them to properly close before the session is closed, e.g. sending stanzas. Also allow stanzas to be sent while the session is in closing status.
Fixes issue
#41.→ <<cset f34be24b0009>>
-
repo owner - changed status to closed
- Log in to comment
Do you have a stacktrace or sample code for reproduction?