Code Monkey home page Code Monkey logo

openfeign-build-image-error's Introduction

Sample OpenFeign Initialization Error Project

This project demonstrates a Spring Feign client lazy initialization error, when using CompletableFuture.supplyAsync() to trigger Feign client initialization.

Project Contents

The project contains a feign client that fetches http://www.google.com. This client is used directly by a rest controller. By design, Feign clients in Spring are lazily initialized, thus leaving initialization to the first caller. In this case, the calling rest controller uses CompletableFuture.supplyAsync() to handle the outbound Feign call asynchronously.

Project Build

The project can be built using:

./gradlew clean bootBuildImage

Error Behavior

The Spring Boot application contained in this project can be tested successfully, as follows:

./gradlew clean bootRun
curl http://localhost:8080/api/sample

This should yield the output from http://www.google.com, fetched by the Feign client.

However, when running the very same application from within Docker, as follows

./gradlew clean bootBuildImage
docker-compose up
curl http://localhost:8080/api/sample

the Feign client initialization will fail with

java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.condition.OnPropertyCondition

When looking at the stack-trace, it is obvious that the ForkJoinWorkerThread in a Docker image built using the Spring Boot Build Image plugin seems to cause this error when trying to lazily initialize the Feign client. The error seems to be strongly related to the Spring Boot Build Image, since using jib instead, does not cause this error.

The same is true for running the Docker image in certain Kubernetes environments, although not all environments seem to be affected.

openfeign-build-image-error's People

Contributors

maverick1601 avatar

Watchers

James Cloos avatar

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.