Skip to content

Commit

Permalink
Clean up JnlpSlaveRestarterInstaller (jenkinsci#7302)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Oct 26, 2022
1 parent a3d1e0c commit 074d8c6
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ public Void call() throws Exception {
install(c, listener);
return null;
}
}

private static void install(Computer c, TaskListener listener) {
try {
final List<SlaveRestarter> restarters = new ArrayList<>(SlaveRestarter.all());
private static void install(Computer c, TaskListener listener) {
try {
final List<SlaveRestarter> restarters = new ArrayList<>(SlaveRestarter.all());

VirtualChannel ch = c.getChannel();
if (ch == null) return; // defensive check
VirtualChannel ch = c.getChannel();
if (ch == null) return; // defensive check

List<SlaveRestarter> effective = ch.call(new FindEffectiveRestarters(restarters));
List<SlaveRestarter> effective = ch.call(new FindEffectiveRestarters(restarters));

LOGGER.log(FINE, "Effective SlaveRestarter on {0}: {1}", new Object[] {c.getName(), effective});
} catch (Throwable e) {
Functions.printStackTrace(e, listener.error("Failed to install restarter"));
LOGGER.log(FINE, "Effective SlaveRestarter on {0}: {1}", new Object[] {c.getName(), effective});
} catch (Throwable e) {
Functions.printStackTrace(e, listener.error("Failed to install restarter"));
}
}
}

Expand All @@ -81,12 +81,6 @@ public List<SlaveRestarter> call() throws IOException {
Engine e = Engine.current();
if (e == null) return null; // not running under Engine

try {
Engine.class.getMethod("addListener", EngineListener.class);
} catch (NoSuchMethodException ignored) {
return null; // running with older version of remoting that doesn't support adding listener
}

// filter out ones that doesn't apply
restarters.removeIf(r -> !r.canWork());

Expand Down

0 comments on commit 074d8c6

Please sign in to comment.