Skip to content

Commit

Permalink
Merge pull request #42 from jenkinsci/safe-listener-fire
Browse files Browse the repository at this point in the history
[FIXED JENKINS-28062] A Channel.Listener's onClose method that propagate...
  • Loading branch information
stephenc committed Apr 23, 2015
2 parents 2b6a021 + b60df6b commit 846b3e0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/hudson/remoting/Channel.java
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
}
}
}

Expand Down

0 comments on commit 846b3e0

Please sign in to comment.