You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each time Feign.Builder.build() is used to build a new Feign instance, it calls enrich to apply the Capabilitys. The MicrometerCapability then wraps the Client, Encoder, Decoder etc. in MeteredXxx decorators. So with each time I build a new Feign from the same Builder, the decorator chain grows by one, so I get e.g a MeteredDecoder wrapped in a MeteredDecoder wrapped in a MeteredDecoder and so on. In our case, this caused a StackOverflowError after the application ran for a while.
Suggestion: Check if the Decoder is already an instance of MeteredDecoder and skip wrapping if it is. (Same for the other objects as well, of course.) But beware: This will not help if you have two capabilities that decorate these objects, because then one capability might only see the decorator from the other capability, not its own...
Other option: Change the code in Feign.Builder to apply the capabilities only once.
The text was updated successfully, but these errors were encountered:
Thanks @radio-rogal, you are of course right, both my suggestions are flawed. Thinking about it some more, it occurs to me that the Capability mechanism should not modify the builder at all. Instead, the builder could feed the results of enriching directly into the objects it creates when the build() method is called. What do you think?
Each time
Feign.Builder.build()
is used to build a newFeign
instance, it callsenrich
to apply theCapability
s. TheMicrometerCapability
then wraps theClient
,Encoder
,Decoder
etc. inMeteredXxx
decorators. So with each time I build a newFeign
from the sameBuilder
, the decorator chain grows by one, so I get e.g aMeteredDecoder
wrapped in aMeteredDecoder
wrapped in aMeteredDecoder
and so on. In our case, this caused aStackOverflowError
after the application ran for a while.Suggestion: Check if the
Decoder
is already an instance ofMeteredDecoder
and skip wrapping if it is. (Same for the other objects as well, of course.) But beware: This will not help if you have two capabilities that decorate these objects, because then one capability might only see the decorator from the other capability, not its own...Other option: Change the code in
Feign.Builder
to apply the capabilities only once.The text was updated successfully, but these errors were encountered: