Fix NetworkTopologyImpl#getLeaves returning set with null value in case of non existing scope

Descriptions of the changes in this PR:

NetworkTopologyImpl#getLeaves(String scope) was returning set with null value, when requested scope did not exist.
I've added null check in NetworkTopologyImpl#doGetLeaves(String scope), used by NetworkTopologyImpl#getLeaves method to not have null node returned as leaf node.

It would be nice to have this merged also with non master branch of bookeeper so maintenance releases could have that fix.

### Motivation
I've found my Apache Pulsar cluster polluted with log:
 12:01:46.462 pulsar2-dev pulsar-broker {"logLevel":"ERROR","logThread":"pulsar-io-23-1","logger":"org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl","message":"found non-BookieNode: null as leaf of defaultrack: /default-rack","stack_trace":null}

After digging I've found that, because
was returning HashSet with null node, when no bookkeepers were in /default-rack.

### Changes
- Modified doGetLeaves() method to return empty HashSet instead of HashSet with null element when scope node can't be found.

Reviewers: Enrico Olivelli <>, Andrey Yegorov <>

This closes #2632 from mkozioro/fix-do-get-leaves
2 files changed
tree: d1b8405bd671ab62b6ca2f5fd6f277c2d54c3511
  1. .github/
  2. .gitignore
  3. .test-infra/
  4. Jenkinsfile
  8. bin/
  9. bookkeeper-benchmark/
  10. bookkeeper-common-allocator/
  11. bookkeeper-common/
  12. bookkeeper-dist/
  13. bookkeeper-http/
  14. bookkeeper-proto/
  15. bookkeeper-server/
  16. bookkeeper-stats-providers/
  17. bookkeeper-stats/
  18. buildtools/
  19. circe-checksum/
  20. conf/
  21. cpu-affinity/
  22. deploy/
  23. dev/
  24. docker/
  25. metadata-drivers/
  26. microbenchmarks/
  27. pom.xml
  28. shaded/
  29. site/
  30. site2/
  31. stats/
  32. stream/
  33. tests/
  34. tools/

Build Status Build Status Coverage Status Maven Central

Apache BookKeeper

Apache BookKeeper is a scalable, fault tolerant and low latency storage service optimized for append-only workloads.

It is suitable for being used in following scenarios:

  • WAL (Write-Ahead-Logging), e.g. HDFS NameNode.
  • Message Store, e.g. Apache Pulsar.
  • Offset/Cursor Store, e.g. Apache Pulsar.
  • Object/Blob Store, e.g. storing state machine snapshots.

Get Started

  • Checkout the project website.
  • Concepts: Start with the basic concepts of Apache BookKeeper. This will help you to fully understand the other parts of the documentation.
  • Follow the Install guide to setup BookKeeper.


Please visit the Documentation from the project website for more information.

Get In Touch

Report a Bug

For filing bugs, suggesting improvements, or requesting new features, help us out by opening a Github issue or opening an Apache jira.

Need Help?

Subscribe or mail the list - Ask questions, find answers, and also help other users.

Subscribe or mail the list - Join development discussions, propose new ideas and connect with contributors.

Join us on Slack - This is the most immediate way to connect with Apache BookKeeper committers and contributors.


We feel that a welcoming open community is important and welcome contributions.

Contributing Code

  1. See Developer Setup to get your local environment setup.

  2. Take a look at our open issues: JIRA Issues Github Issues.

  3. Review our coding style and follow our pull requests to learn about our conventions.

  4. Make your changes according to our contribution guide.

Improving Website and Documentation

  1. See Building the website and documentation on how to build the website and documentation.