Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8114261

TableColumn: should protect itself against null comparator

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Withdrawn
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx

      Description

          
          @Test
          public void testDefaultComparator() {
              TableColumn<String> column = new TableColumn<String>("some");
              assertNotNull(column.getComparator());
              column.setComparator(null);
              assertNotNull(column.getComparator());
          }
          
      Implementation intention seem to be to use TableColumn.DEFAULT_COMPARATOR if none provided by client code. That's working until the first write access to the comparatorProperty: after that, any value is passed on to the property.

      To fix, either implement a custom property which falls back to a default (might be a nice little general property, maybe already hidden somewhere in the code base?) or implement setComparator with a guard:

      public void setComparator(Comparator c) {
             comparatorProperty().set(c != null ? c : DEFAULT)
      }

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              fastegal Jeanette Winzenburg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: