-
Notifications
You must be signed in to change notification settings - Fork 636
Read x-death count in a safer way #3006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read x-death count in a safer way #3006
Conversation
18e3b08
to
b85d809
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build has failed due to Checkstyle violations:
Error: eckstyle] [ERROR] /home/runner/work/spring-amqp/spring-amqp/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/support/DefaultMessagePropertiesConverter.java:36:1: Wrong order for 'org.springframework.util.NumberUtils' import. [ImportOrder]
> Task :spring-rabbit:checkstyleMain
Error: eckstyle] [ERROR] /home/runner/work/spring-amqp/spring-amqp/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/support/DefaultMessagePropertiesConverter.java:153:33: 'if' is not followed by whitespace. [WhitespaceAfter]
Error: eckstyle] [ERROR] /home/runner/work/spring-amqp/spring-amqp/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/support/DefaultMessagePropertiesConverter.java:153:33: 'if' is not followed by whitespace. [WhitespaceAround]
Also, please, add your name to the @author
list of the affected classes.
In other place of the same class I just do:
if (value instanceof Number numberValue) {
target.setRetryCount(numberValue.longValue());
}
Instead of NumberUtils
.
I mean you still have problem with Checkstyle, so might be better to not use it at all 😄
Please, run gradlew check
command locally before pushing.
Head branch was pushed to by a user without write access
Signed-off-by: Raul Avila <[email protected]>
034d987
to
eaa38be
Compare
Apologies for the slightly messy commit, I had some restrictions in my company laptop and couldn't do a proper build. Everything sorted now, any comments let me know. |
Thank you for contribution; looking forward for more! |
Fixes: #3006 We had an issue in our system trying to consume a message from RabbitMQ that contained an `x-death` header, with count value typed as `Integer`. This caused a `ClassCastException`. The reason the count value was an int and not a long is that we were storing headers in an internal database as part of a recovery process, and the typing was slightly changed during serialisation / deserialisation. * Use `target.setRetryCount(numberValue.longValue());` in the `DefaultMessagePropertiesConverter` instead of cast to `long` Signed-off-by: Raul Avila <[email protected]> [[email protected] Improve commit message] Signed-off-by: Artem Bilan <[email protected]> (cherry picked from commit 1741803)
We had an issue in our system trying to consume a message from RabbitMQ that contained an
x-death
header, withcount
value typed as Integer. This caused a ClassCastException inspring-amqp/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/support/DefaultMessagePropertiesConverter.java
Line 150 in 355be1e
The reason the
count
value was an int and not a long is that we were storing headers in an internal database as part of a recovery process, and the typing was slightly changed during serialisation / deserialisation.We propose this pull request to make the reading process of the
count
field inx-death
header safer.