Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Fix rackaware placement policy init error (apache#12097)
Since the release of Pulsar 2.8 and upgrade to BK 4.12, the default rackAwarePlacementPolicy has been failing with the following exception: ``` org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl - Failed to initialize DNS Resolver org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping, used default subnet resolver : java.lang.RuntimeException: java.lang.NullPointerException java.lang.NullPointerException ``` This regression occured in commit apache@4c60262 The core of the issue is that `setConf` is called before `setBookieAddressResolver` has been set (see https://github.com/apache/bookkeeper/blob/034ef8566ad037937a4d58a28f70631175744f53/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java#L264-L286) This results in the NPE. We are safe to simply not eagerly init the cache in setConf as the getRack call will re-check the cache. We also protect against this possible NPE for safety (cherry picked from commit 9975fe4)
- Loading branch information