handle ConnectionRefusalException (#10655)
Changelog Drafter / update_draft_release (push) Waiting to run Details
Changelog Drafter / jenkins_io_draft (push) Waiting to run Details
Label conflicting PRs / main (push) Waiting to run Details

This commit is contained in:
Kris Stern 2025-05-19 00:01:46 +08:00 committed by GitHub
commit 0d5bfdad38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -53,6 +53,7 @@ import jenkins.slaves.RemotingVersionInfo;
import jenkins.websocket.WebSocketSession;
import jenkins.websocket.WebSockets;
import org.jenkinsci.remoting.engine.JnlpConnectionState;
import org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponse;
@ -104,7 +105,12 @@ public final class WebSocketAgents extends InvisibleAction implements Unprotecte
cookie = JnlpAgentReceiver.generateCookie();
}
properties.put(JnlpConnectionState.COOKIE_KEY, cookie);
state.fireAfterProperties(Collections.unmodifiableMap(properties));
try {
state.fireAfterProperties(Collections.unmodifiableMap(properties));
} catch (ConnectionRefusalException e) {
LOGGER.log(Level.WARNING, e.getMessage());
throw HttpResponses.errorWithoutStack(400, e.getMessage());
}
Capability remoteCapability = Capability.fromASCII(remoteCapabilityStr);
LOGGER.fine(() -> "received " + remoteCapability);
rsp.setHeader(Capability.KEY, new Capability().toASCII());