Skip to content

RestTemplate with OkHttp3ClientHttpRequestFactory does not allow the app to stop #5446

@alexey-anufriev

Description

@alexey-anufriev

Prerequisite

I have a simple Spring Boot app that does a single call to https://google.com via RestTemplate.

RestTemplate is just customized a bit, it consumes OkHttp3ClientHttpRequestFactory as a request factory.

Problem

HTTP call is being executed correctly but after finishing the main method application still keeps running and does not stop.

What is the reason for that and how to avoid this behavior?

Reproducer

Reproducible source code: https://github.com/alexey-anufriev/okhttpclient-shutdown-problem

Important Note

The problem occurs only on Java 11, but not on Java 8. On Java 8 it terminates immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug in existing codestackoverflowReferred to stackoverflow

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions