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
In what version(s) of Spring AMQP are you seeing this issue?
From 3.2.0
Describe the bug
Following the retry algorithm example here (which uses the new retryCount message property) can result in an UnsupportedOperationException being thrown from DefaultMessagePropertiesConverter.fromMessageProperties().
This happens if the message doesn't have any other headers.
DefaultMessagePropertiesConverter.fromMessageProperties() currently does this:
The problem is that convertHeadersIfNecessary() does this if the source message has no headers:
...
if (CollectionUtils.isEmpty(headers)) {
returnCollections.emptyMap();
}
...
Collections.emptyMap() returns an unmodifiable Map (more specifically an instance of Collections.EmptyMap) so headers.put() will then result in an UnsupportedOperationException.
To Reproduce
Create a MessageProperties instance, increment the retry count and convert the message using DefaultMessagePropertiesConverter:
Fixesspring-projects#2949
The handling of retryCount is moved into convertHeadersIfNecessary(),
so that we can still return a Collections.emptyMap() if there are no headers
in the source MessageProperties and no retryCount to add.
Signed-off-by: Johan Kaving <[email protected]>
…erter`
Fixes: #2949
Issue link: #2949
* The handling of `retryCount` is moved into `convertHeadersIfNecessary()`,
so that we can still return a `Collections.emptyMap()` if there are no headers
in the source `MessageProperties` and no `retryCount` to add.
Signed-off-by: Johan Kaving <[email protected]>
[[email protected] improve commit message]
Signed-off-by: Artem Bilan <[email protected]>
(cherry picked from commit f621b86)
In what version(s) of Spring AMQP are you seeing this issue?
From 3.2.0
Describe the bug
Following the retry algorithm example here (which uses the new
retryCount
message property) can result in anUnsupportedOperationException
being thrown fromDefaultMessagePropertiesConverter.fromMessageProperties()
.This happens if the message doesn't have any other headers.
DefaultMessagePropertiesConverter.fromMessageProperties()
currently does this:The problem is that
convertHeadersIfNecessary()
does this if the source message has no headers:Collections.emptyMap()
returns an unmodifiableMap
(more specifically an instance ofCollections.EmptyMap
) soheaders.put()
will then result in anUnsupportedOperationException
.To Reproduce
Create a
MessageProperties
instance, increment the retry count and convert the message usingDefaultMessagePropertiesConverter
:Expected behavior
It should be possible to use
retryCount
even if the message doesn't have other headers.The text was updated successfully, but these errors were encountered: