Description
In what version(s) of Spring Integration are you seeing this issue?
6.4.2
Describe the bug
The RequestHandlerRetryAdvice class in spring-integration uses a RetryTemplate to implement retry logic. This template can be instrumented with a MetricsRetryListener (provided by the spring-retry project) to collect Micrometer metrics. However, when this listener is added, RequestHandlerRetryAdvice fails with a NullPointerException on every received message.
The issue stems from how MetricsRetryListener uses the RetryCallback.getLabel() method to populate the name
tag of the timer metric:
Unfortunately, the RetryCallback implementation used internally by RequestHandlerRetryAdvice returns null
for this method.
To Reproduce
- Create a RetryTemplate instance.
- Instrument it with Micrometer using the MetricsRetryListener.
- Create a RequestHandlerRetryAdvice instance and configure it with the retry template.
- Attach the advice to an endpoint.
The advice will fail on every message with a NullPointerException.
Expected behavior
The retry advice should function normally, even when MetricsRetryListener is used. Ideally, the name
tag in the retry metric should default to the endpoint's id, or alternatively, be configurable via a setter on RequestHandlerRetryAdvice.
As a more advanced solution, RequestHandlerRetryAdvice could attach its own RetryListener to instrument retry operations, consistent with how other observations are collected within the spring-integration project.