Skip to content

Commit 9809b49

Browse files
committed
Account for port being blank
1 parent 8017cce commit 9809b49

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/test/java/org/jvnet/hudson/test/JenkinsRuleNonLocalhost.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import javax.servlet.ServletContext;
3636

37+
import org.apache.commons.lang3.StringUtils;
3738
import org.eclipse.jetty.http.HttpCompliance;
3839
import org.eclipse.jetty.http.UriCompliance;
3940
import org.eclipse.jetty.server.HttpConfiguration;
@@ -95,9 +96,10 @@ public Thread newThread(Runnable r) {
9596
System.err.println("Listening on host address: " + HOST);
9697
connector.setHost(HOST);
9798

98-
if (System.getProperty("port")!=null) {
99-
LOGGER.info("Overriding port using system property: " + System.getProperty("port"));
100-
connector.setPort(Integer.parseInt(System.getProperty("port")));
99+
String customPort = System.getProperty("port");
100+
if (StringUtils.isNotBlank(customPort)) {
101+
LOGGER.info("Overriding port using system property: " + customPort);
102+
connector.setPort(Integer.parseInt(customPort));
101103
} else {
102104
if (port != null) {
103105
connector.setPort(port);

0 commit comments

Comments
 (0)