Skip to content

Commit 0d5bfda

Browse files
authored
handle ConnectionRefusalException (#10655)
2 parents 86a6fd8 + 9b08d12 commit 0d5bfda

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

core/src/main/java/jenkins/agents/WebSocketAgents.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import jenkins.websocket.WebSocketSession;
5454
import jenkins.websocket.WebSockets;
5555
import org.jenkinsci.remoting.engine.JnlpConnectionState;
56+
import org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException;
5657
import org.kohsuke.accmod.Restricted;
5758
import org.kohsuke.accmod.restrictions.NoExternalUse;
5859
import org.kohsuke.stapler.HttpResponse;
@@ -104,7 +105,12 @@ public HttpResponse doIndex(StaplerRequest2 req, StaplerResponse2 rsp) throws IO
104105
cookie = JnlpAgentReceiver.generateCookie();
105106
}
106107
properties.put(JnlpConnectionState.COOKIE_KEY, cookie);
107-
state.fireAfterProperties(Collections.unmodifiableMap(properties));
108+
try {
109+
state.fireAfterProperties(Collections.unmodifiableMap(properties));
110+
} catch (ConnectionRefusalException e) {
111+
LOGGER.log(Level.WARNING, e.getMessage());
112+
throw HttpResponses.errorWithoutStack(400, e.getMessage());
113+
}
108114
Capability remoteCapability = Capability.fromASCII(remoteCapabilityStr);
109115
LOGGER.fine(() -> "received " + remoteCapability);
110116
rsp.setHeader(Capability.KEY, new Capability().toASCII());

0 commit comments

Comments
 (0)