-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
[JENKINS-35272] Prevent duplicate invocation of Launcher.afterDisconnect #26142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
062beb8
80e5c10
61288a3
cc3ff1f
1c28a5a
1a540c6
2f60669
f200ce7
408fdf8
01fe1fd
ed223f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -134,6 +134,12 @@ public class SlaveComputer extends Computer { | |||||
| */ | ||||||
| private final TaskListener taskListener; | ||||||
|
|
||||||
| /** | ||||||
| * Flag to ensure afterDisconnect() is called only once per connection. | ||||||
| */ | ||||||
|
|
||||||
| private volatile boolean afterDisconnectCalled = false; | ||||||
|
|
||||||
|
|
||||||
| /** | ||||||
| * Number of failed attempts to reconnect to this node | ||||||
|
|
@@ -650,6 +656,7 @@ public void onClosed(Channel c, IOException cause) { | |||||
| Functions.printStackTrace(cause, taskListener.error("Connection terminated")); | ||||||
| } | ||||||
| closeChannel(); | ||||||
| safeAfterDisconnect(); // changed from direct call to safe method to avoid multiple calls | ||||||
| try { | ||||||
| launcher.afterDisconnect(SlaveComputer.this, taskListener); | ||||||
| } catch (Throwable t) { | ||||||
|
|
@@ -745,6 +752,10 @@ public void onClosed(Channel c, IOException cause) { | |||||
| this.absoluteRemoteFs = remoteFS; | ||||||
| defaultCharset = Charset.forName(defaultCharsetName); | ||||||
|
|
||||||
| // Reset the flag for the new connection | ||||||
|
|
||||||
RajThak-998 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| afterDisconnectCalled = false; | ||||||
|
|
||||||
| synchronized (statusChangeLock) { | ||||||
| statusChangeLock.notifyAll(); | ||||||
| } | ||||||
|
|
@@ -769,6 +780,25 @@ public void onClosed(Channel c, IOException cause) { | |||||
| Jenkins.get().getQueue().scheduleMaintenance(); | ||||||
| } | ||||||
|
|
||||||
| private void safeAfterDisconnect() { | ||||||
| if(!afterDisconnectCalled){ | ||||||
| synchronized (this){ | ||||||
| if(!afterDisconnectCalled){ | ||||||
MarkEWaite marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
MarkEWaite marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| afterDisconnectCalled = true; | ||||||
| try{ | ||||||
|
||||||
| try{ | |
| try { |
RajThak-998 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space before opening brace to follow standard Java formatting conventions. It should be '} catch (Throwable t) {' instead of '} catch (Throwable t){'.
| } catch (Throwable t){ | |
| } catch (Throwable t) { |
Uh oh!
There was an error while loading. Please reload this page.