Existing configuration
- Kotlin 1.8.0
- Spring Boot 2.7.8
- Spring Cloud Dependencies 2021.0.5
- Spring Cloud OpenFeign 3.1.5
- Spring Cloud Sleuth 3.1.5
- Kotest
Changed configuration
- Kotlin 1.8.0
- Spring Boot 3.0.2
- Spring Cloud Dependencies 2022.0.0
- Spring Cloud OpenFeign 4.0.0
- micrometer-tracing-bridge-brave 1.0.1
- Kotest
Problem
FeignClient related test code uploaded with @SpringBootTest fails
Detailed description
The corresponding FeignClient has a custom class that inherits SpringDecoder as a setting.
This SpringDecoder decodes the body for a response with an HTTP status code of 200 OK, and writes a logic that throws a custom exception that inherits FeignException according to the value of a specific field inside after decode.
The test code mocked the response to be returned when calling FeignClient's method with Wiremock.
In the Boot 2.7.x version, all test codes passed normally, but when the version was upgraded to Boot 3, Cloud Dependencies 2022.0.0, the test codes were broken.
Pseudo code
/// FeignClient
@FeignClient(
configuration = [
CustomSpringDecoder::class,
]
)
interface MtlClient { }
// SpringDecoder
class CustomSpringDecoder(
messageConverters: ObjectFactory<HttpMessageConverters>,
customizers: ObjectProvider<HttpMessageConverterCustomizer>,
) : SpringDecoder(messageConverters, customizers) {
override fun decode(response: Response, type: Type): Any { }
More information
It was a part of a business project, so I couldn't create a sample project that accurately reproduces it. sorry 😓
However, the version upgrade affects the operation of SpringDecoder, so the existing test code seems to fail. However, SpringDecoder's source code confirmed that all Cloud Dependencies 2021.0.5 and 2022.0.0 are the same.
I'm guessing something changed in the SpringDecoder.decode() method.
Please advise if there is any information about this phenomenon, and if not, what part I can additionally check. No matter how I think about it, this phenomenon is strange and leaves an issue.
Please share any related changes and even small clues 🙏
Comment From: doljae
I found the cause.
It seems that the response body composed of ByteArray is created only when the logger related settings (@Configuration, yml, etc.) are properly set.
I changed the logger related settings to something suitable for the Boot 3 version and it was resolved.