Skip to content
Permalink
Browse files

Merge pull request #42 from jenkinsci/safe-listener-fire

[FIXED JENKINS-28062] A Channel.Listener's onClose method that propagate...
  • Loading branch information...
stephenc committed Apr 23, 2015
2 parents 2b6a021 + b60df6b commit 846b3e0527aa1dc5629a2a7e870f4b7efb653cfb
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/main/java/hudson/remoting/Channel.java
@@ -55,6 +55,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

/**
@@ -829,8 +830,16 @@ public void terminate(IOException e) {
} // JENKINS-14909: leave synch block
} finally {
if (e instanceof OrderlyShutdown) e = null;
for (Listener l : listeners.toArray(new Listener[0]))
l.onClosed(this, e);
for (Listener l : listeners.toArray(new Listener[0])) {
try {
l.onClosed(this, e);
} catch (Throwable t) {
LogRecord lr = new LogRecord(Level.SEVERE, "Listener {0} propagated an exception for channel {1}'s close: {2}");
lr.setThrown(t);
lr.setParameters(new Object[]{l, this, t.getMessage()});
logger.log(lr);
}
}
}
}

0 comments on commit 846b3e0

Please sign in to comment.
You can’t perform that action at this time.