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

Potential NPE in RunnableOnMaster #2498

Closed
kwin opened this issue Dec 17, 2020 · 0 comments
Closed

Potential NPE in RunnableOnMaster #2498

kwin opened this issue Dec 17, 2020 · 0 comments
Milestone

Comments

@kwin
Copy link
Contributor

kwin commented Dec 17, 2020

The class RunnableOnMaster implements a TopologyEventListener and dereferences TopologyEvent.getNewView() in its handleTopologyEvent method (

this.isLeader = te.getNewView().getLocalInstance().isLeader();
).

This might lead to a NPE as getNewView might return null (https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/org/apache/sling/discovery/TopologyEvent.html#getNewView--). In general it is not wise to rely on the TopologyEventListener just to figure out if the current instance is the leader, as you cannot predict when the topology events are received. Instead one should rely on DiscoveryService.getTopologyView() as that always gives the current status.

A similar issue was detected in #2492

kwin added a commit to kwin/acs-aem-commons that referenced this issue Dec 21, 2020
Automatically generate service of that type.
Leverage from JcrPackageReplicationStatusEventHandler and
TwitterFeedScheduler.

This closes Adobe-Consulting-Services#2492 Adobe-Consulting-Services#2498
@kwin kwin added this to the 4.12.0 milestone Dec 21, 2020
kwin added a commit that referenced this issue Mar 3, 2021
Automatically generate service of that type.
Leverage from JcrPackageReplicationStatusEventHandler and
TwitterFeedScheduler.

This closes #2492 #2498
@kwin kwin closed this as completed Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant