Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Implemented
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Release
    • Component/s: framework
    • Labels:
      None

      Description

      • AuthenticationComparator.java:31, SE_COMPARATOR_SHOULD_BE_SERIALIZABLE
        Se: org.apache.ofbiz.common.authentication.AuthenticationComparator implements Comparator but not Serializable

      This class implements the Comparator interface. You should consider whether or not it should also implement the Serializable interface. If a comparator is used to construct an ordered collection such as a TreeMap, then the TreeMap will be serializable only if the comparator is also serializable. As most comparators have little or no state, making them serializable is generally easy and good defensive programming.

      • AuthenticationComparator.java:70, CO_COMPARETO_INCORRECT_FLOATING
        compareTo()/compare() incorrectly handles float or double value

      This method compares double or float values using pattern like this: val1 > val2 ? 1 : val1 < val2 ? -1 : 0. This pattern works incorrectly for -0.0 and NaN values which may result in incorrect sorting result or broken collection (if compared values are used as keys). Consider using Double.compare or Float.compare static methods which handle all the special cases correctly.

        Activity

        Hide
        Dennis Balkir Dennis Balkir added a comment -
        • implementation of Serializable is not necessary
          method compare:
        • changed the comparison to Float.compare
        • made a local parameter comp to save the value from Float.compare to use it
        • instead of returning -1 or 1 it now returns the result of Float.compare put through Math.signum (which then only returns -1 or 1)
        • deleted unnecessary else
        Show
        Dennis Balkir Dennis Balkir added a comment - implementation of Serializable is not necessary method compare: changed the comparison to Float.compare made a local parameter comp to save the value from Float.compare to use it instead of returning -1 or 1 it now returns the result of Float.compare put through Math.signum (which then only returns -1 or 1) deleted unnecessary else
        Hide
        mbrohl Michael Brohl added a comment -

        Thanks Dennis,

        your patch is in trunk r1811421.

        Show
        mbrohl Michael Brohl added a comment - Thanks Dennis, your patch is in trunk r1811421.

          People

          • Assignee:
            mbrohl Michael Brohl
            Reporter:
            Dennis Balkir Dennis Balkir
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development