Skip to content

Comments

ARTEMIS-5099 fix impossible cast in AMQPLargeMessage#5448

Closed
jbertram wants to merge 1 commit intoapache:mainfrom
jbertram:ARTEMIS-5099
Closed

ARTEMIS-5099 fix impossible cast in AMQPLargeMessage#5448
jbertram wants to merge 1 commit intoapache:mainfrom
jbertram:ARTEMIS-5099

Conversation

@jbertram
Copy link
Contributor

I believe this was likely a copy-and-paste error involving o.a.a.a.c.p.i.j.LargeServerMessageImpl#referenceOriginalMessage.

I believe this was likely a copy-and-paste error involving
o.a.a.a.c.p.i.j.LargeServerMessageImpl#referenceOriginalMessage.
super.referenceOriginalMessage(original, originalQueue);

if (original instanceof LargeServerMessageImpl) {
if (original instanceof AMQPLargeMessage) {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@clebertsuconic
Copy link
Contributor

I removed the code, and pushed the commit directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants