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

Tree-/TableCell: NPE when accessing edit event from startEdit

XMLWordPrintable

      failing test:

          @Test
          public void testEditStartEventAfterStartOnCell() {
              setupForEditing();
              int editingIndex = 1;
              cell.updateIndex(editingIndex);
              List<CellEditEvent<?, ?>> events = new ArrayList<>();
              editingColumn.setOnEditStart(events::add);
              cell.startEdit();
              assertEquals(editingColumn, events.get(0).getTableColumn());
          }

      underlying reason is startEdit creating the event with an incorrect location:

                  CellEditEvent<S,?> editEvent = new CellEditEvent<>(
                      table,
                       table.getEditingCell(),
                      TableColumn.editStartEvent(),
                      null
                  );

      issue is that table might not yet be in editing state (JDK-8187474),
      fix is similar to that of the corresponding issue for ListCell JDK-8187432 - use cell state to create the tablePosition

      Note: the NPE (vs. having an incorrect location) is caused by JDK-8269871 which accesses properties of the position without null guard

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

              Created:
              Updated:
              Resolved: