Skip to content

Commit

Permalink
Fix potential npe bug of apache#14384 (apache#14595)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaozhangmin authored Mar 9, 2022
1 parent 9895f0b commit 7c1f17a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ private URI initializeDlogNamespace() throws IOException {
}
BKDLConfig bkdlConfig = new BKDLConfig(ledgersStoreServers, ledgersRootPath);
DLMetadata dlMetadata = DLMetadata.create(bkdlConfig);
URI dlogURI = URI.create(String.format("distributedlog://%s/pulsar/packages",
configuration.getZookeeperServers()));
URI dlogURI = URI.create(String.format("distributedlog://%s/pulsar/packages", ledgersStoreServers));
try {
dlMetadata.create(dlogURI);
} catch (ZKException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setup() throws Exception {
PackagesStorageProvider provider = PackagesStorageProvider
.newProvider(BookKeeperPackagesStorageProvider.class.getName());
DefaultPackagesStorageConfiguration configuration = new DefaultPackagesStorageConfiguration();
configuration.setProperty("zookeeperServers", zkUtil.getZooKeeperConnectString());
configuration.setProperty("metadataStoreUrl", zkUtil.getZooKeeperConnectString());
configuration.setProperty("packagesReplicas", "1");
configuration.setProperty("packagesManagementLedgerRootPath", "/ledgers");
storage = provider.getStorage(configuration);
Expand All @@ -68,7 +68,7 @@ public void teardown() throws Exception {
public void testConfiguration() {
assertTrue(storage instanceof BookKeeperPackagesStorage);
BookKeeperPackagesStorage bkStorage = (BookKeeperPackagesStorage) storage;
assertEquals(bkStorage.configuration.getZookeeperServers(), zkUtil.getZooKeeperConnectString());
assertEquals(bkStorage.configuration.getMetadataStoreUrl(), zkUtil.getZooKeeperConnectString());
assertEquals(bkStorage.configuration.getPackagesReplicas(), 1);
assertEquals(bkStorage.configuration.getPackagesManagementLedgerRootPath(), "/ledgers");
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public void testReadWriteOperationsWithSeparatedBkCluster() throws Exception {
.newProvider(BookKeeperPackagesStorageProvider.class.getName());
DefaultPackagesStorageConfiguration configuration = new DefaultPackagesStorageConfiguration();
// set the unavailable bk cluster with mock zookeeper path
configuration.setProperty("zookeeperServers", zkUtil.getZooKeeperConnectString() + "/mock");
configuration.setProperty("metadataStoreUrl", zkUtil.getZooKeeperConnectString() + "/mock");
configuration.setProperty("packagesReplicas", "1");
configuration.setProperty("packagesManagementLedgerRootPath", "/ledgers");
PackagesStorage storage1 = provider.getStorage(configuration);
Expand All @@ -221,7 +221,7 @@ public void testReadWriteOperationsWithSeparatedBkCluster() throws Exception {
// set the available bk cluster with bookkeeperMetadataServiceUri using actual zookeeper path
String bookkeeperMetadataServiceUri = String.format("zk+null://%s/ledgers", zkUtil.getZooKeeperConnectString());
DefaultPackagesStorageConfiguration configuration2 = new DefaultPackagesStorageConfiguration();
configuration2.setProperty("zookeeperServers", zkUtil.getZooKeeperConnectString());
configuration2.setProperty("metadataStoreUrl", zkUtil.getZooKeeperConnectString());
configuration2.setProperty("bookkeeperMetadataServiceUri", bookkeeperMetadataServiceUri);
configuration2.setProperty("packagesReplicas", "1");
PackagesStorage storage2 = provider.getStorage(configuration2);
Expand Down

0 comments on commit 7c1f17a

Please sign in to comment.