Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Proper freeing of resources (e.g. output-thread) when connection is
closed [JENKINS-25349]
Don't know why I disabled this initially.
  • Loading branch information
kutzi committed Nov 1, 2014
1 parent 6b1f4fa commit 98b0105
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main/java/hudson/plugins/ircbot/v2/IRCConnection.java
Expand Up @@ -87,13 +87,18 @@ public IRCConnection(DescriptorImpl descriptor, AuthenticationHolder authenticat
public void close() {
this.listener.explicitDisconnect = true;

if (this.pircConnection != null && this.pircConnection.isConnected()) {
this.listener.removeJoinListener(this);
this.listener.removePartListener(this);
this.listener.removeInviteListener(this);

this.pircConnection.disconnect();
//this.pircConnection.shutdown();
if (this.pircConnection != null) {
if (this.pircConnection.isConnected()) {
this.listener.removeJoinListener(this);
this.listener.removePartListener(this);
this.listener.removeInviteListener(this);

this.pircConnection.disconnect();
}

// Perform a proper shutdown, also freeing all the resources (input-/output-thread)
// Note that with PircBotx 2.x the threads are gone and we can maybe simplify this
this.pircConnection.shutdown(true);
}
}

Expand Down

0 comments on commit 98b0105

Please sign in to comment.