Skip to content

Support concurrent behavior on MetricsRetryListener #467

@huisam

Description

@huisam

Hello Spring team. I was glad to hear that official support MetricsRetryListener class by this issue #458

But I have a question about this class behavior.

Question

The retryContextToSample field is considered for reusable many retry operations.
And the RetryListener can be registered by bean from RetryConfiguration class.

If the MetricsRetryListener registered by bean, the MetricsRetryListener can called by concurrent retry operations.

In conclusion, my question is why retryContextToSample was defined to IdentityHashMap ?

private final Map<RetryContext, Timer.Sample> retryContextToSample = new IdentityHashMap<>();

On IdentityHashMap javadoc, it doesn't support thread safe behavior.

Suggestion

Can you support the thread safe behavior from the retryContextToSample?

private final Map<RetryContext, Timer.Sample> retryContextToSample = new ConcurrentHashMap<>();

Discussion

Please feel free to comment on this issue. If my suggestion is wrong, then I will close this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions