pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[fix][client] Prevent NPE when seeking with null topic in TopicMessageId

Open 3pacccccc opened this issue 6 months ago • 0 comments

Motivation

This PR addresses a potential NullPointerException (NPE) that could occur when calling the seek() method with a TopicMessageIdImpl that has a null topic.

Modifications

  1. Added null check for the owner topic in MultiTopicsConsumerImpl.java before attempting to access it
  2. Added comprehensive test case in SubscriptionSeekTest.java to verify the fix:
    • Creates a partitioned topic
    • Attempts to seek using a TopicMessageIdImpl with null topic
    • Verifies the proper exception is thrown with a clear error message

Verifying this change

  • [x] Make sure that the change passes the CI checks.

If the box was checked, please highlight the changes

  • [ ] Dependencies (add or upgrade a dependency)
  • [ ] The public API
  • [ ] The schema
  • [ ] The default values of configurations
  • [ ] The threading model
  • [ ] The binary protocol
  • [ ] The REST endpoints
  • [ ] The admin CLI options
  • [ ] The metrics
  • [ ] Anything that affects deployment

Documentation

  • [ ] doc
  • [ ] doc-required
  • [x] doc-not-needed
  • [ ] doc-complete

Matching PR in forked repository

PR in forked repository: https://github.com/3pacccccc/pulsar/pull/8

3pacccccc avatar Jun 12 '25 13:06 3pacccccc