Skip to content
Permalink
Browse files

[JENKINS-38678] Properly remove administrative monitors from the Exte…

…nsionList (#2577)

* [JENKINS-38678] Remove properly administrative monitor

previous impl didn't work because ExtensionList#iterator() returns a
readonly iterator.

* Use foreach loop
  • Loading branch information...
Vlatombe authored and oleg-nenashev committed Oct 10, 2016
1 parent 67df10d commit d86825620225520194ac49a69ea1e7039e31145f
Showing with 7 additions and 4 deletions.
  1. +7 −4 core/src/main/java/jenkins/model/Jenkins.java
@@ -1214,16 +1214,19 @@ private void launchTcpSlaveAgentListener() throws IOException {
tcpSlaveAgentListener = null;
}
if (slaveAgentPort != -1 && tcpSlaveAgentListener == null) {
String administrativeMonitorId = getClass().getName() + ".tcpBind";
final String administrativeMonitorId = getClass().getName() + ".tcpBind";
try {
tcpSlaveAgentListener = new TcpSlaveAgentListener(slaveAgentPort);
// remove previous monitor in case of previous error
for (Iterator<AdministrativeMonitor> it = AdministrativeMonitor.all().iterator(); it.hasNext(); ) {
AdministrativeMonitor am = it.next();
AdministrativeMonitor toBeRemoved = null;
ExtensionList<AdministrativeMonitor> all = AdministrativeMonitor.all();
for (AdministrativeMonitor am : all) {
if (administrativeMonitorId.equals(am.id)) {
it.remove();
toBeRemoved = am;
break;
}
}
all.remove(toBeRemoved);
} catch (BindException e) {
LOGGER.log(Level.WARNING, String.format("Failed to listen to incoming agent connections through JNLP port %s. Change the JNLP port number", slaveAgentPort), e);
new AdministrativeError(administrativeMonitorId,

0 comments on commit d868256

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