Skip to content
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

[pulsar-client] NPE while call getLastMessageId #6561

Closed
murong00 opened this issue Mar 19, 2020 · 0 comments · Fixed by #6562
Closed

[pulsar-client] NPE while call getLastMessageId #6561

murong00 opened this issue Mar 19, 2020 · 0 comments · Fixed by #6562
Assignees
Labels
release/2.5.1 type/bug The PR fixed a bug or issue reported a bug
Milestone

Comments

@murong00
Copy link
Contributor

Describe the bug
Meet NPE while call getLastMessageId as below:

[root@xxx apache-pulsar-2.6.0-SNAPSHOT]# bin/pulsar-admin topics last-message-id persistent://public/default/test
java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.apache.pulsar.client.impl.BatchMessageIdImpl["acker"]->org.apache.pulsar.client.impl.BatchMessageAcker["outstandingAcks"])
        at org.apache.pulsar.admin.cli.CliCommand.print(CliCommand.java:182)
        at org.apache.pulsar.admin.cli.CmdTopics$GetLastMessageId.run(CmdTopics.java:773)
        at org.apache.pulsar.admin.cli.CmdBase.run(CmdBase.java:71)
        at org.apache.pulsar.admin.cli.PulsarAdminTool.run(PulsarAdminTool.java:221)
        at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:263)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.apache.pulsar.client.impl.BatchMessageIdImpl["acker"]->org.apache.pulsar.client.impl.BatchMessageAcker["outstandingAcks"])
        at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
        at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:353)
        at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:316)
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:730)
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:166)
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:727)
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:722)
        at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:166)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
        at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
        at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1433)
        at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1135)
        at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:1005)
        at org.apache.pulsar.admin.cli.CliCommand.print(CliCommand.java:180)
        ... 4 more
Caused by: java.lang.NullPointerException
        at org.apache.pulsar.client.impl.BatchMessageAcker.getOutstandingAcks(BatchMessageAcker.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:688)
        at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:722)
        ... 14 more

The reason is that BatchMessageIdImpl use a default BatchMessageAcker with null value.

Expected behavior
getLastMessageId should be successful like below:

[root@xxx apache-pulsar-2.6.0-SNAPSHOT]# bin/pulsar-admin topics last-message-id persistent://public/default/test
{
  "ledgerId" : 5,
  "entryId" : 0,
  "partitionIndex" : -1,
  "batchIndex" : 9,
  "acker" : {
    "batchSize" : 0,
    "prevBatchCumulativelyAcked" : false,
    "outstandingAcks" : 0
  },
  "outstandingAcksInSameBatch" : 0,
  "batchSize" : 0
}

@murong00 murong00 added the type/bug The PR fixed a bug or issue reported a bug label Mar 19, 2020
@codelipenghui codelipenghui added this to the 2.6.0 milestone Mar 19, 2020
sijie pushed a commit that referenced this issue Mar 19, 2020
### Motivation

Fixes #6561

### Modifications

Initialize `BatchMessageAckerDisabled` with a `new BitSet()` Object.
tuteng pushed a commit to AmateurEvents/pulsar that referenced this issue Mar 21, 2020
### Motivation

Fixes apache#6561

### Modifications

Initialize `BatchMessageAckerDisabled` with a `new BitSet()` Object.

(cherry picked from commit 2007de6)
tuteng pushed a commit that referenced this issue Apr 6, 2020
### Motivation

Fixes #6561

### Modifications

Initialize `BatchMessageAckerDisabled` with a `new BitSet()` Object.

(cherry picked from commit 2007de6)
tuteng pushed a commit that referenced this issue Apr 13, 2020
### Motivation

Fixes #6561

### Modifications

Initialize `BatchMessageAckerDisabled` with a `new BitSet()` Object.

(cherry picked from commit 2007de6)
jiazhai pushed a commit to jiazhai/pulsar that referenced this issue May 18, 2020
### Motivation

Fixes apache#6561

### Modifications

Initialize `BatchMessageAckerDisabled` with a `new BitSet()` Object.
(cherry picked from commit 2007de6)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this issue Aug 24, 2020
### Motivation

Fixes apache#6561

### Modifications

Initialize `BatchMessageAckerDisabled` with a `new BitSet()` Object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/2.5.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants