Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-390

BeanComparator throws exception for null property values

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.8.3
    • Fix Version/s: None
    • Component/s: Bean-Collections
    • Labels:
      None

      Description

      When using a BeanComparator to sort on a bean property that may contain null values, an exception is thrown. By default, the BeanComparator uses a ComparableComparator internally. ComparableComparator in turn throws a NullPointerException when it attempts to compare to a null value. My proposed solution is extending BeanComparator with a new class, NullSafeBeanComparator, that incorporates logic from NullComparator. I have a working example and will attach it.

        Attachments

        1. NullSafeBeanComparator.java
          2 kB
          Matthew Toso

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              takaitra Matthew Toso
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: