Openfire (ARCHIVED)

HttpSession#getVersion() tests for equality to NaN

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 3.5.0
  • Fix Version/s: 3.6.0
  • Component/s: Core
  • Labels:
    None
  • Acceptance Test - Add?:
    No

Description

HttpSession uses the NaN (Not a Number) value to represent a 'unset' version. When getting the number, it checks if the stored version equal to NaN, based on which it will return the version number, or a default. The NaN equality check that is used will always fail though, as described by FindBugs:

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).

Activity

Hide
Guus der Kinderen added a comment -

I've replaced the != comparator with Double.isNan() in revision 10253.

Show
Guus der Kinderen added a comment - I've replaced the != comparator with Double.isNan() in revision 10253.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: