-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #2667 The `x-delay` header may arrive as a `Short` from RabbitMQ broker. * Fix `DefaultMessagePropertiesConverter.toMessageProperties()` to deal with a `Number` to extract `long` value from the `x-delay` header # Conflicts: # spring-rabbit/src/main/java/org/springframework/amqp/rabbit/support/DefaultMessagePropertiesConverter.java
- Loading branch information
1 parent
3941c12
commit f8308f2
Showing
1 changed file
with
7 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ | |
* @author Mark Fisher | ||
* @author Gary Russell | ||
* @author Soeren Unruh | ||
* @author Artem Bilan | ||
* | ||
* @since 1.0 | ||
*/ | ||
public class DefaultMessagePropertiesConverter implements MessagePropertiesConverter { | ||
|
@@ -92,8 +94,10 @@ public MessageProperties toMessageProperties(final BasicProperties source, final | |
String key = entry.getKey(); | ||
if (MessageProperties.X_DELAY.equals(key)) { | ||
Object value = entry.getValue(); | ||
if (value instanceof Integer integ) { | ||
target.setReceivedDelay(integ); | ||
if (value instanceof Number numberValue) { | ||
int receivedDelayLongValue = numberValue.intValue(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
artembilan
Author
Member
|
||
target.setReceivedDelay(receivedDelayLongValue); | ||
target.setHeader(key, receivedDelayLongValue); | ||
} | ||
} | ||
else { | ||
|
@@ -174,7 +178,7 @@ private Map<String, Object> convertHeadersIfNecessary(Map<String, Object> header | |
} | ||
|
||
/** | ||
* Converts a header value to a String if the value type is unsupported by AMQP, also handling values | ||
* Convert a header value to a String if the value type is unsupported by AMQP, also handling values | ||
* nested inside Lists or Maps. | ||
* <p> {@code null} values are passed through, although Rabbit client will throw an IllegalArgumentException. | ||
* @param valueArg the value. | ||
|
Can we make sure this is a positive number here? It was observed in the past, for whatever reason, recevedDelay was set to a negative number.