Improve watcher test by preventing a npe when closing the http client.

This commit is contained in:
Martijn van Groningen 2020-02-24 10:22:48 +01:00
parent 7cefba78c5
commit 225d841212
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 6 additions and 3 deletions

View File

@ -76,9 +76,10 @@ import static org.mockito.Mockito.when;
public class HttpClientTests extends ESTestCase { public class HttpClientTests extends ESTestCase {
private MockWebServer webServer = new MockWebServer(); private final MockWebServer webServer = new MockWebServer();
private final Environment environment = TestEnvironment.newEnvironment(Settings.builder().put("path.home", createTempDir()).build());
private HttpClient httpClient; private HttpClient httpClient;
private Environment environment = TestEnvironment.newEnvironment(Settings.builder().put("path.home", createTempDir()).build());
@Before @Before
public void init() throws Exception { public void init() throws Exception {
@ -92,7 +93,9 @@ public class HttpClientTests extends ESTestCase {
@After @After
public void shutdown() throws IOException { public void shutdown() throws IOException {
webServer.close(); webServer.close();
httpClient.close(); if (httpClient != null) {
httpClient.close();
}
} }
public void testBasics() throws Exception { public void testBasics() throws Exception {