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

BeanComparator throws exception for null property values

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 1.8.3
    • None
    • Bean-Collections
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: