The web application [...] appears to have started a thread named [OkHttp <tenant>.auth0.com] but has failed to stop it

Please include the following information in your post:

  • Which SDK this is regarding: Java (com.auth0:auth0:1.42.0)
  • SDK Version: 1.42.0
  • Platform Version: Java 8

On shutdown of the web application there is numerous error messages regarding OkHttp threads not being stopped, causing a memory leak. Am I missing something, or is there no method for shutting down these threads?

Aug 02, 2022 4:52:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [] appears to have started a thread named [OkHttp Dispatcher] 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:750)
Aug 02, 2022 4:52:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [] appears to have started a thread named [OkHttp .auth0.com] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
java.net.SocketInputStream.read(SocketInputStream.java:171)
java.net.SocketInputStream.read(SocketInputStream.java:141)
sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:475)
sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:469)
sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:69)
sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1266)
sun.security.ssl.SSLSocketImpl.access$300(SSLSocketImpl.java:76)
sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:943)
okio.InputStreamSource.read(JvmOkio.kt:90)
okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129)
okio.RealBufferedSource.request(RealBufferedSource.kt:206)
okio.RealBufferedSource.require(RealBufferedSource.kt:199)
okhttp3.internal.http2.Http2Reader.nextFrame(Http2Reader.kt:89)
okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:618)
okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:609)
okhttp3.internal.concurrent.TaskQueue$execute$1.runOnce(TaskQueue.kt:98)
okhttp3.internal.concurrent.TaskRunner.runTask(TaskRunner.kt:116)
okhttp3.internal.concurrent.TaskRunner.access$runTask(TaskRunner.kt:42)
okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:65)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:750)
Aug 02, 2022 4:52:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [] appears to have started a thread named [OkHttp TaskRunner] 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.internal.concurrent.TaskRunner$RealBackend.coordinatorWait(TaskRunner.kt:294)
okhttp3.internal.concurrent.TaskRunner.awaitTaskToRun(TaskRunner.kt:218)
okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:59)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:750)
Aug 02, 2022 4:52:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [] appears to have started a thread named [OkHttp TaskRunner] 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:750)
Aug 02, 2022 4:52:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [] appears to have started a thread named [OkHttp TaskRunner] 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:750)
Aug 02, 2022 4:52:28 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: 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$Companion.awaitTimeout$okio(AsyncTimeout.kt:300)
okio.AsyncTimeout$Watchdog.run(AsyncTimeout.kt:187)

Apologies for bumping it up - we are doing our backlog clean-up, so I thought I would update this topic with the discussion thread on our GitHub Issues page. You may find there references for the problem resolution:

Warm regards,
Marcelina