mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Shutdown listenerExecutor to prevent the Thread from leaking
listenerExecutor needs to get shutdown once it is no longer required. SMACK-567
This commit is contained in:
parent
f1f7713513
commit
f4f7eca7ca
1 changed files with 15 additions and 0 deletions
|
@ -1318,4 +1318,19 @@ public abstract class XMPPConnection {
|
||||||
public FromMode getFromMode() {
|
public FromMode getFromMode() {
|
||||||
return this.fromMode;
|
return this.fromMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
try {
|
||||||
|
// It's usually not a good idea to rely on finalize. But this is the easiest way to
|
||||||
|
// avoid the "Smack Listener Processor" leaking. The thread(s) of the executor have a
|
||||||
|
// reference to their ExecutorService which prevents the ExecutorService from being
|
||||||
|
// gc'ed. It is possible that the XMPPConnection instance is gc'ed while the
|
||||||
|
// listenerExecutor ExecutorService call not be gc'ed until it got shut down.
|
||||||
|
listenerExecutor.shutdownNow();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue