Skip to content

MessageId#compare is not symmetric (MessageIdImpl, BatchMessageIdImpl) #6433

Description

@racorn

Describe the bug
Given to MessageIds, of which one happens to be a MessageIdImpl and the other is a BatchMessageIdImpl, the compare method is not symmetric.

To Reproduce

import static org.assertj.core.api.Assertions.assertThat;
@Test
public void shouldBeSymmetric() {

    MessageIdImpl simpleMessageId = new MessageIdImpl(1, 2, 3);
    BatchMessageIdImpl batchMessageId = new BatchMessageIdImpl(1, 2, 3, 0);
    assertThat(simpleMessageId.compareTo(batchMessageId)).isEqualTo(batchMessageId.compareTo(simpleMessageId));

    }

Expected behavior
MessageId#compare should be symmetric

Additional context
Pulsar 2.5.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions