title: WireMock per test-case setup hanging on second test
body: <p>I'm using WireMock to test a Spring Boot web app that, itself uses Jetty, though on different ports. </p>
  
  <p>What I'm seeing is that, if I use the basic Rule configuration:</p>
  
  <pre><code>@Rule
  public WireMockRule wireMockRule = new WireMockRule(8006); 
  </code></pre>
  
  <p>and I use <code>stubFor</code> in a <code>@Before</code> method, and then immediately follow that up with a call to the stubbed URL (via Spring's <code>RestTemplate</code>), the first test case works without a hitch, but then the second test case hangs. The bit of relevant stack trace is:</p>
  
  <pre><code>"main" prio=10 tid=0x00007f60a4009000 nid=0xb8d0 runnable [0x00007f60abcec000]
      java.lang.Thread.State: RUNNABLE
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:146)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
      - locked &lt;0x00000000f33e8d00&gt; (a java.io.BufferedInputStream)
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:688)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
      at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:767)
      at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1162)
      - locked &lt;0x00000000f33da7c8&gt; (a sun.net.www.protocol.http.HttpURLConnection)
      at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:397)
      at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:48)
      at org.springframework.http.client.AbstractClientHttpResponse.getStatusCode(AbstractClientHttpResponse.java:33)
      at org.springframework.web.client.DefaultResponseErrorHandler.getHttpStatusCode(DefaultResponseErrorHandler.java:56)
      at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:50)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:542)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:502)
      at org.springframework.web.client.RestTemplate.put(RestTemplate.java:381)
  </code></pre>
  
  <p>If I instead use the static methods shown on the 'Getting Started' page, everything works fine. I'm fine with going with the static method so that WireMock is started/stopped once per class, but for my own edification I would love to know why the other case isn't working as expected.</p>
  
  <p>UPDATE: Just noticed that after ~200 seconds, the test fails with:</p>
  
  <pre><code>nested exception is java.net.SocketException: Unexpected end of file from server
  </code></pre>
  
  <p>Thanks,
  Justin</p>