Skip to content
Permalink
Browse files

[FIXED JENKINS-28062] A Channel.Listener's onClose method that propag…

…ates an exception is a sign of a bad listener not a problem closing the channel.
  • Loading branch information...
stephenc committed Apr 23, 2015
1 parent 2b6a021 commit b60df6b39caa403f29845b86338579d1cf76b819
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 b60df6b

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