You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2022/07/29 10:04:44 UTC

[shardingsphere-elasticjob] branch master updated: Update ServerStatisticsAPIImpl.java (#2108)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9fec9e51c Update ServerStatisticsAPIImpl.java (#2108)
9fec9e51c is described below

commit 9fec9e51c2d031381a107372fe804d1c5feb3b47
Author: Jovons <zh...@hotmail.com>
AuthorDate: Fri Jul 29 18:04:40 2022 +0800

    Update ServerStatisticsAPIImpl.java (#2108)
    
    jobInstance from unmarshalled can be null. And thereafter it throws NPE error.
---
 .../lifecycle/internal/statistics/ServerStatisticsAPIImpl.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImpl.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImpl.java
index 0e736286e..deb798798 100644
--- a/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImpl.java
+++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/main/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/internal/statistics/ServerStatisticsAPIImpl.java
@@ -68,10 +68,12 @@ public final class ServerStatisticsAPIImpl implements ServerStatisticsAPI {
             List<String> instances = regCenter.getChildrenKeys(jobNodePath.getInstancesNodePath());
             for (String each : instances) {
                 JobInstance jobInstance = YamlEngine.unmarshal(regCenter.get(jobNodePath.getInstanceNodePath(each)), JobInstance.class);
-                ServerBriefInfo serverInfo = servers.get(jobInstance.getServerIp());
-                if (null != serverInfo) {
-                    serverInfo.getInstances().add(each);
-                    serverInfo.setInstancesNum(serverInfo.getInstances().size());
+                if (null != jobInstance) {
+                    ServerBriefInfo serverInfo = servers.get(jobInstance.getServerIp());
+                    if (null != serverInfo) {
+                        serverInfo.getInstances().add(each);
+                        serverInfo.setInstancesNum(serverInfo.getInstances().size());
+                    }
                 }
             }
         }