Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-7676

Nullcheck would have been NPE in BlacklistEntry

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: EJBCA 6.9.0
    • Fix Version/s: EJBCA 7.0.0, EJBCA 6.15.2
    • Component/s: None
    • Labels:
    • Sprint:
      EJBCA Team Bob - 2019 w2

      Description

      Findbugs reports:

      org.ejbca.core.model.validation.BlacklistEntry.java:114 CORRECTNESS	RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE	Normal
      
      Nullcheck of newEntry at line 115 of value previously dereferenced in org.ejbca.core.model.validation.BlacklistEntry.diff(BlacklistEntry)
      
      A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.
      

      newEntry != null should probably be newEntry.getValue() != null in the following:

          public Map<Object, Object> diff(BlacklistEntry newEntry) {
              Map<Object, Object> result = new LinkedHashMap<Object, Object>();
              if (!StringUtils.equals(this.getValue(), newEntry.getValue())) {
                  result.put("changed:value", newEntry != null ? newEntry.getValue() : "null");
              }
              if (!StringUtils.equals(this.getData(), newEntry.getData())) {
                  result.put("changed:data", newEntry != null ? newEntry.getData() : "null");
              }
              return result;
          }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              johan Johan Eklund
              Reporter:
              johan Johan Eklund
              Verified by:
              Samuel Lidén Borell
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: