Skip to content

Commit

Permalink
fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
VGalaxies committed Mar 16, 2024
1 parent d56ad10 commit 66122a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hugegraph.pd;

import java.util.List;
import java.util.Objects;

import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.pd.config.PDConfig;
Expand Down Expand Up @@ -128,7 +129,11 @@ public synchronized PDConfig setPartitionCount(int count) {
* @throws PDException when io error
*/
public int getPartitionCount() throws PDException {
return getPDConfig().getPartitionCount();
Metapb.PDConfig config = getPDConfig();
if (Objects.nonNull(config)) {
return config.getPartitionCount();
}
return pdConfig.getInitialPartitionCount();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public void shutDown() {
}

public boolean isLeader() {
if (Objects.isNull(this.raftNode)) {
return false;
}
return this.raftNode.isLeader(true);
}

Expand Down

0 comments on commit 66122a6

Please sign in to comment.