HttpSession#getVersion() tests for equality to NaN
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).
Environment
None
Activity
Guus der Kinderen
April 23, 2008 at 12:09 PM
I've replaced the != comparator with Double.isNan() in revision 10253.
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: