Giter Site home page Giter Site logo

[BUG] azure-storage-blob library with azure-core-http-okhttp client prevents application from termination for 60 seconds. about azure-sdk-for-java HOT 4 CLOSED

if-of avatar if-of commented on September 7, 2024
[BUG] azure-storage-blob library with azure-core-http-okhttp client prevents application from termination for 60 seconds.

from azure-sdk-for-java.

Comments (4)

alzimmermsft avatar alzimmermsft commented on September 7, 2024

Thank you for filing this question @if-of.

Did some investigation, this appears to be the default behavior of OkHttp's Dispatcher class, which in turn by default we don't modify when OkHttp is being used leaving that configuration to the application to handle.

Looking at Dispatcher it uses a ThreadFactory that creates non-daemon threads for the ExecutorService backing the Dispatcher (https://github.com/square/okhttp/blob/master/okhttp/src/main/kotlin/okhttp3/Dispatcher.kt#L103, https://github.com/square/okhttp/blob/master/okhttp/src/main/kotlin/okhttp3/internal/-UtilJvm.kt#L65).

The good news, our OkHttp HttpClient builder allows for configuration of the Dispatcher being used. So, a simple work around could be supplying your own Dispatcher that doesn't use daemon threads, therefore prevents the Dispatcher from preventing JVM shutdown while the threads time out in the ExecutorService.

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-okhttp/src/main/java/com/azure/core/http/okhttp/OkHttpAsyncHttpClientBuilder.java#L298

from azure-sdk-for-java.

if-of avatar if-of commented on September 7, 2024

Thank you, @alzimmermsft. Your workaround effectively solved my issue, eliminating the 60-second wait time.

P.S: It's quite unfortunate that this isn't the default behavior. However, considering the simplicity of the fix, it's not much of an inconvenience.

from azure-sdk-for-java.

github-actions avatar github-actions commented on September 7, 2024

Hi @if-of. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

from azure-sdk-for-java.

github-actions avatar github-actions commented on September 7, 2024

Hi @if-of, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.

from azure-sdk-for-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.