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

CellEditEvent: must not throw NPE in accessors

XMLWordPrintable

      Happens if instantiated with null tablePosition (stumbling over it triggered JDK-8187229, though the underlying reason of that is different - incorrect edit location).

      Misbehavior was introduced when fixing JDK-8120610 (by removing null guard of tablePosition without updating the accessors to cope with null pos). Also effects default onCommit handlers which went unnoticed because of .. unusual tests.

      example of failing tests (for TableColumn.CellEditEvent, similar for TreeTableColumn.CellEditEvent):

          /**
           * NPE with not-null table on accessing table.
           */
          @Test
          public void testNullTablePosition() {
              CellEditEvent<String, String> ev = new CellEditEvent<>(table, null, editAnyEvent(), null);
              ev.getTableView();
          }

      ----
        
      Note: the part below was originally included in this issue, on further analysis moved to JDK-8271474

      - throws NPE if instantiated with null table

      might be considered a strengthening of precondition, because the table is passed as source to super. Arguably, though because that role is an implementation detail. At least, it should be specified as requiring not-null

        
          /**
           * Strengthened precondition: event must handle null source.
           */
          @Test
          public void testNullTable() {
              CellEditEvent<?, ?> ev = new CellEditEvent<Object, Object>(null, // null table
                      new TablePosition<>(null, -1, null), editAnyEvent(), null);
          }
          

            fastegal Jeanette Winzenburg
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: