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

TableColumn: should protect itself against null comparator

XMLWordPrintable

          
          @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)
      }

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

              Created:
              Updated:
              Resolved:
              Imported: