NullPointerException using the DialogComponentColumnFilter class

When I try to create an org.knime.core.node.defaultnodesettings.DialogComponentColumnFilter object with an org.knime.core.node.defaultnodesettings.SettingsModelFilterString and the default exclude list is not empty I get a java.lang.NullPointerException.
The problem is that in this case the local variable update gets true value before the settings have been loaded. And in this case the call getLastTableSpec(m_inPortIndex) returns null, which will be dereferenced in org.knime.core.node.util.ColumnFilterPanel.update(DataTableSpec, boolean, Collection) (or throws an assertion error if assertions enabled).
Am I doing something wrong, or is it intentional? (If the latter case: why are not deprecated the settings model’s constructors with includes and excludes?)

PS: Is there a better place to report bugs? I was unable to find it (not in the FAQs, and nor using site search).

Hi aborg,
I’m afraid you found a bug. And i don’t really have a workaround. Sorry.

  • Peter.
    P.S. Reporting bugs in the forum or through personal mail is still the only possible way.

I spent a bit more time thinking about your problem: The constructor is not the right place to specify the default values. At construction time you don’t know the table spec, thus you don’t really know which columns to put into the exclude/include list. (Still, throwing a NPE is not the right thing to do and must be fixed on our end.) The values set in the model at construction time are replaced by the values loaded in when the dialog opens. And these values loaded in are provided by the NodeModel. So, to work around the NPE, specify an empty SettingsModel in the constructor. And in the NodeModel#configure method set the default values in the corresponding SettingsModel (at that point in time you have the table spec at hand and can set the correct values). These values will be transfered into the dialog then (through NodeMode#saveSettings and NodeDialog#loadSettings).
I hope it make sense.

  • Peter.

Hi Peter,

Thank you very much for investigating the problem. I was sure I do something wrong, but because I have not seen any deprecation signs at the constructor I was brave enough to use it. :slight_smile: (Actually I have only specified some excluded columns, so if those were not in the list of possible columns that would make no problems.)
Kind Regards, gabor