apache / apache/pulsar

Java client consumer acknowledge issue. It should work for both of the cases

Open
#12,962 6 comments 0 reactions 0 assignees View on GitHub
lifecycle/stale type/bug
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

**Describe the bug**
Hi, I found an issue in java client library. When consumer tried to acknowledge, if consumer acknowledge like following, its working:
`consumer.acknowledge(message.getMessageId())`
But if I do following, it’s failed:
`consumer.acknowledge(MessageId.fromByteArray(message.getMessageId().toByteArray()))`
Ideally, both of the cases should work. There should be something wrong with serialization and deserialization of MessageId’s toByteArray and fromByteArray method.
An exception will be thrown if I use second method for acknowledging:
`java.lang.IllegalArgumentException: null
at org.apache.pulsar.shade.com.google.common.base.Preconditions.checkArgument(Preconditions.java:128) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.MultiTopicsConsumerImpl.doAcknowledge(MultiTopicsConsumerImpl.java:425) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.doAcknowledgeWithTxn(ConsumerBase.java:554) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.acknowledgeAsync(ConsumerBase.java:494) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.acknowledgeAsync(ConsumerBase.java:483) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.acknowledge(ConsumerBase.java:313) ~[pulsar-client-2.8.1.jar:2.8.1]`
**To Reproduce**
Steps to reproduce the behavior:
1. Do consumer acknowledge with `consumer.acknowledge(MessageId.fromByteArray(message.getMessageId().toByteArray()))`
2. Exception thrown:
`java.lang.IllegalArgumentException: null
at org.apache.pulsar.shade.com.google.common.base.Preconditions.checkArgument(Preconditions.java:128) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.MultiTopicsConsumerImpl.doAcknowledge(MultiTopicsConsumerImpl.java:425) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.doAcknowledgeWithTxn(ConsumerBase.java:554) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.acknowledgeAsync(ConsumerBase.java:494) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.acknowledgeAsync(ConsumerBase.java:483) ~[pulsar-client-2.8.1.jar:2.8.1]
at org.apache.pulsar.client.impl.ConsumerBase.acknowledge(ConsumerBase.java:313) ~[pulsar-client-2.8.1.jar:2.8.1]`

**Expected behavior**
It should work like `consumer.acknowledge(message.getMessageId())`

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Start with the Java client MessageId.fromByteArray and toByteArray methods, then follow the acknowledge path through MultiTopicsConsumerImpl.doAcknowledge shown in the stack trace. Reproduce both acknowledge calls and add regression coverage so the serialized-and-deserialized MessageId acknowledges successfully without the IllegalArgumentException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.