You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/01/17 10:49:37 UTC

[shardingsphere] branch master updated: Fix NPE when load instance worker id (#14834)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new d809738  Fix NPE when load instance worker id (#14834)
d809738 is described below

commit d809738aa6907b3526e162d1c80530b08ff1fafb
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Mon Jan 17 18:48:51 2022 +0800

    Fix NPE when load instance worker id (#14834)
---
 .../mode/metadata/persist/service/ComputeNodePersistService.java       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
index b80052d..96464b3 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/persist/service/ComputeNodePersistService.java
@@ -91,7 +91,8 @@ public final class ComputeNodePersistService {
      */
     public Long loadInstanceWorkerId(final String instanceId) {
         try {
-            return Long.valueOf(repository.get(ComputeNode.getInstanceWorkerIdNodePath(instanceId)));
+            String workerId = repository.get(ComputeNode.getInstanceWorkerIdNodePath(instanceId));
+            return Strings.isNullOrEmpty(workerId) ? null : Long.valueOf(workerId);
         } catch (final NumberFormatException ex) {
             log.error("Invalid worker id for instance: {}", instanceId);
         }