Skip to content

Commit

Permalink
[JENKINS-73011] Round-trip JNLPLauncher.tunnel to null not "" (j…
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick authored Apr 15, 2024
1 parent 323ad6a commit 13dc52c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/slaves/JNLPLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public String getTunnel() {
*/
@DataBoundSetter
public void setTunnel(String tunnel) {
this.tunnel = tunnel;
this.tunnel = Util.fixEmptyAndTrim(tunnel);
}

@Override
Expand Down
26 changes: 26 additions & 0 deletions test/src/test/java/hudson/slaves/JNLPLauncherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -112,6 +113,31 @@ public void testNoWorkDirMigration() {
jnlpLauncher.getWorkDirSettings().isDisabled());
}

@Issue("JENKINS-73011")
@SuppressWarnings("deprecation")
@Test
public void deprecatedFields() throws Exception {
var launcher = new JNLPLauncher();
launcher.setWebSocket(true);
launcher.setWorkDirSettings(new RemotingWorkDirSettings(false, null, "remoting2", false));
launcher.setTunnel("someproxy");
var agent = j.createSlave();
agent.setLauncher(launcher);
agent = j.configRoundtrip(agent);
launcher = (JNLPLauncher) agent.getLauncher();
assertThat(launcher.isWebSocket(), is(true));
assertThat(launcher.getWorkDirSettings().getInternalDir(), is("remoting2"));
assertThat(launcher.getTunnel(), is("someproxy"));
launcher = new JNLPLauncher();
launcher.setWebSocket(true);
agent.setLauncher(launcher);
agent = j.configRoundtrip(agent);
launcher = (JNLPLauncher) agent.getLauncher();
assertThat(launcher.isWebSocket(), is(true));
assertThat(launcher.getWorkDirSettings().getInternalDir(), is("remoting"));
assertThat(launcher.getTunnel(), nullValue());
}

@Test
public void testDefaults() {
assertFalse("Work directory enabled by default", new JNLPLauncher().getWorkDirSettings().isDisabled());
Expand Down

0 comments on commit 13dc52c

Please sign in to comment.