Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9878

Code smell in if statement

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 6.4, 7.0
    • None
    • None

    Description

      In recent code snapshot (Github mirror's commit id: c8542b2bd0470af9f8d64bb8133f31828b342604 as today), there is an illogical condition that can be a code smell or a potential bug:

      ReversedWildcardFilterFactory fac = leadingWildcards.get(fieldType);
          if (fac != null || leadingWildcards.containsKey(fac)) {
            return fac;
          }
      

      In SOLR-3492, it said there was a fix in SOLR-4093. However, the fix still has an issue as above: containsKey will always have null in this if statement. The second condition could be unnecessary. Does leadingWildcards allow a null object as a key? If so, it will return null that might cause NPE in some other locations.

      Patch could be just like in SOLR-3492?:

      if (fac != null)
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            lifove JC
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment