GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][broker][branch-3.0] Prevent NPE in ownedBundlesCountPerNamespace on first bundle load by nodece · Pull Request #24758 · apache/pulsar

Conversation

@nodece

@nodece nodece commented Sep 18, 2025

Copy link
Copy Markdown
Member

Motivation

Fix NPE:

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.atomic.AtomicInteger.incrementAndGet()" because the return value of "java.util.Map.get(Object)" is null

  at org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService.addOwnedNamespaceBundleAsync(SystemTopicBasedTopicPoliciesService.java:405) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService$2.onLoad(SystemTopicBasedTopicPoliciesService.java:509) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.notifyNamespaceBundleOwnershipListener(NamespaceService.java:1322) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.onNamespaceBundleOwned(NamespaceService.java:1285) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.OwnershipCache.lambda$tryAcquiringOwnership$3(OwnershipCache.java:218) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:684) ~[?:?]

  at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:662) ~[?:?]

  at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2168) ~[?:?]

  at org.apache.pulsar.broker.namespace.OwnershipCache.tryAcquiringOwnership(OwnershipCache.java:216) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.searchForCandidateBroker(NamespaceService.java:631) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at org.apache.pulsar.broker.namespace.NamespaceService.lambda$findBrokerServiceUrl$10(NamespaceService.java:466) ~[pulsar-broker.jar:3.0.14-SNAPSHOT]

  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]

  at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]

  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]

  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]

  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

  at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.124.Final.jar:4.1.124.Final]

  at java.lang.Thread.run(Thread.java:840) ~[?:?]

Modifications

  • Replaced direct ownedBundlesCountPerNamespace.get(...).incrementAndGet() with
    computeIfAbsent(namespace, k -> new AtomicInteger(0)) to ensure the counter is always initialized before incrementing.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodece
[fix][broker] Prevent NPE in ownedBundlesCountPerNamespace on first b…
1ed4c27
…undle load
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Sep 18, 2025
@nodece nodece mentioned this pull request Sep 18, 2025
[fix][broker] PIP-428: Fix corrupted topic policies issues with sequential topic policy updates #24427
Merged
1 of 4 tasks
@lhotari lhotari changed the title [fix][broker] Prevent NPE in ownedBundlesCountPerNamespace on first bundle load [fix][broker][branch-3.0] Prevent NPE in ownedBundlesCountPerNamespace on first bundle load Sep 18, 2025
lhotari
lhotari approved these changes Sep 18, 2025
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nodece reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@lhotari lhotari added the release/3.3.9 label Sep 18, 2025
@nodece
nodece merged commit 6ceb4f8 into apache:branch-3.0 Sep 18, 2025
@nodece
nodece deleted the fix-NPE-ownedBundlesCountPerNamespace branch September 18, 2025 09:17
nodece added a commit to ascentstream/pulsar that referenced this pull request Sep 19, 2025
@nodece
[fix][broker][branch-3.0] Prevent NPE in ownedBundlesCountPerNamespac…
8436cb7
…e on first bundle load (apache#24758)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 19, 2025
@nodece @manas-ctds
[fix][broker][branch-3.0] Prevent NPE in ownedBundlesCountPerNamespac…
52b50d4
…e on first bundle load (apache#24758)

(cherry picked from commit 6ceb4f8)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 19, 2025
@nodece @srinath-ctds
[fix][broker][branch-3.0] Prevent NPE in ownedBundlesCountPerNamespac…
58c31d9
…e on first bundle load (apache#24758)

(cherry picked from commit 6ceb4f8)
@lhotari lhotari added release/3.3.10 and removed release/3.3.9 labels Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

doc-not-needed Your PR changes do not impact docs release/3.3.10

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@nodece @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.