Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      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. In this issue we post a patch which can add  !=null  based on existed !=null  check. For example:

      Callee ClusterDataCache#getStateModelDef:

      public StateModelDefinition getStateModelDef(String stateModelDefRef) {
        if (stateModelDefRef == null) {
          return null;
        }
        return _stateModelDefMap.get(stateModelDefRef);
      }
      

      Caller AutoRebalancer#computeNewIdealState have !=null:

      StateModelDefinition stateModelDef = clusterData.getStateModelDef(stateModelName);
      if (stateModelDef == null) {
        LOG.error("State Model Definition null for resource: " + resourceName);
        throw new HelixException("State Model Definition null for resource: " + resourceName);
      }
      

      but another caller DelayedAutoRebalancer#computeNewIdealState does not have !=null check:

      StateModelDefinition stateModelDef =
          clusterData.getStateModelDef(currentIdealState.getStateModelDefRef());
      LinkedHashMap<String, Integer> stateCountMap =
          stateModelDef.getStateCountMap(activeNodes.size(), replicaCount);
      

      So we will add below code in non-(!=null) caller DelayedAutoRebalancer#computeNewIdealState

      if (stateModelDef == null) {
          throw new HelixException("State Model Definition null for resource:" + resourceName);
      }

       

      But due to we are not very  familiar with HELIX, hope some expert can review it.

      Thanks.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              leigong brettkk
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: