title: OkHTTP Client: Getting memory leak warning on re-deploy application (tomcat)
body: <p>My code:</p>
  
  <pre><code>  OkHttpClient client = new OkHttpClient();
    HttpUrl httpUrl = HttpUrl.parse(url).newBuilder().addQueryParameter("t", Base64.encodeBase64String(value.getBytes())).build();
    Request request = new Request.Builder().url(httpUrl).get().build();
    try (Response response = client.newCall(request).execute()) {
      System.out.println(response.body().string());
    } catch (Exception e) {
      System.out.println(e.toString());
    }
  </code></pre>
  
  <p>Use this code on java 8 + apache-tomcat-9.0.14 + okhttp 3.13.1</p>
  
  <p>Errors in logs on re-deploy:</p>
  
  <pre><code>06-Feb-2019 01:44:05.257 WARNING [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [...] appears to have started a thread named [OkHttp ConnectionPool] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
   java.lang.Object.wait(Native Method)
   java.lang.Object.wait(Object.java:460)
   okhttp3.ConnectionPool.lambda$new$0(ConnectionPool.java:66)
   okhttp3.ConnectionPool$$Lambda$143/649093426.run(Unknown Source) 
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   java.lang.Thread.run(Thread.java:748)
  06-Feb-2019 01:44:05.260 WARNING [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [...] appears to have started a thread named [Okio Watchdog] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
   java.lang.Object.wait(Native Method)
   okio.AsyncTimeout.awaitTimeout(AsyncTimeout.java:348)
   okio.AsyncTimeout$Watchdog.run(AsyncTimeout.java:313)
  06-Feb-2019 01:44:05.260 WARNING [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [...] appears to have started a thread named [OkHttp ConnectionPool] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
   sun.misc.Unsafe.park(Native Method)
   java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
   java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
   java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
   java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:941)
  java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1073)
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>I tried to use force shutdown (from official javadoc) in context shutdown, but still getting warnings.</p>