-
Notifications
You must be signed in to change notification settings - Fork 928
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
ARTEMIS-5099 fix impossible cast in AMQPLargeMessage #5448
base: main
Are you sure you want to change the base?
Conversation
I believe this was likely a copy-and-paste error involving o.a.a.a.c.p.i.j.LargeServerMessageImpl#referenceOriginalMessage.
42a525d
to
2e7c7fc
Compare
@@ -660,7 +659,7 @@ public void referenceOriginalMessage(final Message original, final SimpleString | |||
|
|||
super.referenceOriginalMessage(original, originalQueue); | |||
|
|||
if (original instanceof LargeServerMessageImpl) { | |||
if (original instanceof AMQPLargeMessage) { |
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.
My main question would be what is the impact of adding this call into the mix given that it wasn't happening before and I guess didn't cause anything to break? Would something break now?
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.
When you say, "it wasn't happening before," what exactly do you mean? Do you mean that org.apache.activemq.artemis.core.persistence.impl.journal.LargeBody#referenceOriginalMessage
wasn't being invoked since this instanceof
would never succeed?
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.
I'm not sure what else I could have meant but let me be more clear. What will happen now that an AMQPLargeMessage cast would succeed when this method is called? Should something have been testing this? From a brief look at the broker code calling this it seems like the source message would never be anything other than the AMQPLargeMessage itself so I doubt the cast to ServerLargeMessageImpl would have succeeded in the past.
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.
I think this is supposed to be kept as it was...
it's being tested from TestConversions.. so it is for conversions...
So when you convert from AMQP to Core
It probably needs to add coverage
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.
These two lines break the existing code:
AMQPLargeMessage m = new AMQPLargeMessage(0, 0, null, null, null);
m.referenceOriginalMessage(new LargeServerMessageImpl((byte) 0, 0, null, null), SimpleString.of("foo"));
Causing this to be thrown:
java.lang.ClassCastException: class org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl cannot be cast to class org.apache.activemq.artemis.protocol.amqp.broker.AMQPLargeMessage (org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl and org.apache.activemq.artemis.protocol.amqp.broker.AMQPLargeMessage are in unnamed module of loader 'app')
It's not clear to me that this code is directly related to any conversion. If it was I would expect org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl#referenceOriginalMessage
to behave in a similar way.
I believe this was likely a copy-and-paste error involving o.a.a.a.c.p.i.j.LargeServerMessageImpl#referenceOriginalMessage.