Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-711

Findbugs: Bug: Doomed test for equality to NaN PDFTextStripper.java

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.2.0
    • Component/s: Utilities
    • Labels:
      None

      Description

      org.apache.pdfbox.util.PDFTextStripper.java

      if ((wordSpacing == 0) || (wordSpacing == Float.NaN))

      (wordSpacing == Float.NaN) always fails, should use the method to test the value.

      if ((wordSpacing == 0) || Float.isNaN(wordSpacing )

      Findbugs Description: Bug: Doomed test for equality to NaN
      Pattern id: FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER, type: FE, category: CORRECTNESS

      This code checks to see if a floating point value is equal to the special Not A Number value (e.g., if (x == Double.NaN)). However, because of the special semantics of NaN, no value is equal to Nan, including NaN. Thus, x == Double.NaN always evaluates to false. To check to see if a value contained in x is the special Not A Number value, use Double.isNaN (or Float.isNaN if x is floating point precision).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              peter_lenahan@ibi.com Peter_Lenahan@ibi.com
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: