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

STORM-3051:some Potential NPEs #2655

Closed
wants to merge 2 commits into from
Closed

Conversation

lujiefsi
Copy link
Contributor

@lujiefsi lujiefsi commented May 2, 2018

We have developed a static analysis tool NPEDetector to find some potential NPE. Our analysis shows that some callees may return null in corner case(e.g. node crash , IO exception), some of their callers have !=null check but some do not have.

Bug:

  1. callee CgroupCenter#getSubSystems return null when meet exception:
} catch (Exception e) {
LOG.error("Get subSystems error {}", e);
}
return null;

but its caller use it without check:

public boolean isSubSystemEnabled(SubSystemType subSystemType) {
  Set subSystems = this.getSubSystems();
  for (SubSystem subSystem : subSystems) {
     if (subSystem.getType() == subSystemType) {
     return true;
  }
  }
  return false;
}

other callee and caller pair that have same problem.

  1. callee RAS_Node#getUsedSlots and caller RAS_Node#totalSlotsUsed
  2. CgroupCenter#getHierarchies and caller CgroupCenter#isMounted,

@lujiefsi lujiefsi changed the title fix STORM-3051 STORM-3051:some Potential NPEs May 2, 2018
for (SubSystem subSystem : subSystems) {
if (subSystem.getType() == subSystemType) {
return true;
if (subSystems != null){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space between ) and {

@lujiefsi lujiefsi closed this Oct 23, 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
2 participants