Each IRCConnection starts an input thread and an output thread when
created; if not stopped, these threads continue to hold the IRCService,
resulting in a leak when the service is stopped. Fix this by using
PircBot's dispose() to stop the threads when disposing of the
IRCConnection.
---
application/src/org/yaaic/irc/IRCService.java | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/application/src/org/yaaic/irc/IRCService.java
b/application/src/org/yaaic/irc/IRCService.java
index 83d731a..bac25ad 100644
--- a/application/src/org/yaaic/irc/IRCService.java
+++ b/application/src/org/yaaic/irc/IRCService.java
@@ -368,7 +368,14 @@ public class IRCService extends Service
for (int i = 0; i < mSize; i++) {
server = mServers.get(i);
if (server.isDisconnected()) {
- connections.remove(server.getId());
+ int serverId = server.getId();
+ synchronized(this) {
+ IRCConnection connection = connections.get(serverId);
+ if (connection != null) {
+ connection.dispose();
+ }
+ connections.remove(serverId);
+ }
} else {
shutDown = false;
}
--
1.7.2.5