Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getShardingInfo Report NullPointerException #2452

Open
ExploreHeart opened this issue Oct 23, 2024 · 1 comment
Open

getShardingInfo Report NullPointerException #2452

ExploreHeart opened this issue Oct 23, 2024 · 1 comment

Comments

@ExploreHeart
Copy link

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ElasticJob did you use?

elasticjob 3.0.4

Expected behavior

Actual behavior

java.lang.NullPointerException: null
	at java.io.StringReader.<init>(StringReader.java:50)
	at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:57)
	at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:473)
	at org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine.unmarshal(YamlEngine.java:54)
	at org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.statistics.ShardingStatisticsAPIImpl.getShardingInfo(ShardingStatisticsAPIImpl.java:64)
	at org.apache.shardingsphere.elasticjob.lite.lifecycle.internal.statistics.ShardingStatisticsAPIImpl.getShardingInfo(ShardingStatisticsAPIImpl.java:47)

Reason analyze (If you can)

private ShardingInfo getShardingInfo(final String jobName, final String item) {
       //Obtain the instance. However, the instance may be an offline instance.
        String instanceId = regCenter.get(jobNodePath.getShardingNodePath(item, "instance"));
        if (null != instanceId) {
            // The online instance data is obtained from the instance node based on the offline instance. In this case, the returned result is null.
            JobInstance jobInstance = YamlEngine.unmarshal(regCenter.get(jobNodePath.getInstanceNodePath(instanceId)), JobInstance.class);
            result.setServerIp(jobInstance.getServerIp());
            result.setInstanceId(jobInstance.getJobInstanceId());
        }
    }

Steps to reproduce the behavior.

Example codes for reproduce this issue (such as a github link).

@linghengqian
Copy link
Member

Do you plan to submit PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants