Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e6f3e7

Browse files
committed
more npe fixes
1 parent d55fba4 commit 3e6f3e7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/test/java/com/gargoylesoftware/htmlunit/InsecureHttpsServer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ public void handle(final HttpRequest request, final HttpResponse response, final
112112
};
113113
localServer_.register("*", handler);
114114
}
115-
WebServerTestCase.tryBind(getPort(), () -> localServer_.start());
115+
WebServerTestCase.tryBind(-1, () -> localServer_.start());
116116
}
117117

118118
/**
119119
* Stops the server.
120120
* @throws Exception in case of exception
121121
*/
122122
public void stop() throws Exception {
123-
localServer_.shutDown();
123+
if (localServer_ != null) {
124+
localServer_.shutDown();
125+
}
126+
localServer_ = null;
124127
}
125128

126129
/**

src/test/java/com/gargoylesoftware/htmlunit/SocksProxyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void httpsWithBadProxyPortShouldFail() throws Exception {
9292
private void doHttpsTest(final WebClient webClient) throws Exception {
9393
final InsecureHttpsServer server = new InsecureHttpsServer(SocksProxyTestServlet.HTML);
9494
try {
95-
WebServerTestCase.tryBind(server.getPort(), () -> server.start());
95+
WebServerTestCase.tryBind(-1, () -> server.start());
9696
webClient.getOptions().setUseInsecureSSL(true);
9797

9898
final String url = "https://" + server.getHostName() + ":" + server.getPort();

0 commit comments

Comments
 (0)