Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-816

SimpleBloomFilter: There is no coverage of this branch. It is not possible.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.5.0-M1
    • 4.5.0-M1
    • Collection

    Description

      Copied from Simplify Bloom Filters pull request.

      https://github.com/apache/commons-collections/pull/258#discussion_r815505285

       

      https://github.com/Claudenw/commons-collections/blob/9f2945cc98747893456b73f42ab53f46a866ac37/src/main/java/org/apache/commons/collections4/bloomfilter/SimpleBloomFilter.java#L165-L168

       
       
      Member

      aherbert on 27 Feb

      There is no coverage of this branch. It is not possible. If this were true the bitMap[idx[0]] in the main forEach loop would have thrown an array index out of bound exception. I think this can be removed. The final check to determine if the final upper bitmap does not set incorrect bits is valid.

      Note: Even though the check is made that the upper bits have been set correctly, if they have not the exception is raised and the filter now has incorrect bits for the rest of its lifetime, i.e. no recovery is made and no flag is present in the filter to indicate the bits are bad. So you could then merge this into another filter and get the same exception, or record the bits to file and have bad bits in the recording, etc.

      The same 'bug' is present in the SparseBloomFilter. It will raise an exception after merge if the TreeSet first or last position are outside the shape but not correct it.

      I think these filters should attempt to clear any invalid bits before throwing exceptions. This makes them act as if they are a plain int[] of size nbits containing 0 or 1s. It should not be possible to put an index outside the range of the shape in the filter.

      Attachments

        Issue Links

          Activity

            People

              claude Claude Warren
              claude Claude Warren
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: