rpbouman / pentaho-pdi-plugin-jdbc-metadata

A transformation step for pentaho data integration that gives access to the various metadata resultsets of the JDBC DatabaseMetaData object.
Apache License 2.0
3 stars 8 forks source link

Argument Cannot be Null Exception when trying to edit step after it was saved unconfigured #5

Closed cdeptula closed 9 years ago

cdeptula commented 9 years ago

You get an argument cannot be null exception when you add the step to a transformation, do not fully configure the step, particularly the output fields, save the transformation, close and reopen the transformation, then try to edit the step.

java.lang.IllegalArgumentException: Argument cannot be null at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.widgets.Widget.error(Unknown Source) at org.eclipse.swt.widgets.TableItem.setText(Unknown Source) at org.pentaho.di.steps.jdbcmetadata.JdbcMetaDataDialog.updateOutputFields(JdbcMetaDataDialog.java:332) at org.pentaho.di.steps.jdbcmetadata.JdbcMetaDataDialog.populateDialog(JdbcMetaDataDialog.java:972) at org.pentaho.di.steps.jdbcmetadata.JdbcMetaDataDialog.open(JdbcMetaDataDialog.java:905) at org.pentaho.di.ui.spoon.delegates.SpoonStepsDelegate.editStep(SpoonStepsDelegate.java:124) at org.pentaho.di.ui.spoon.Spoon.editStep(Spoon.java:8720) at org.pentaho.di.ui.spoon.trans.TransGraph.editStep(TransGraph.java:3027) at org.pentaho.di.ui.spoon.trans.TransGraph.mouseDoubleClick(TransGraph.java:744) at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source) at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source) at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source) at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1310) at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:7931) at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:9202) at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:648) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.pentaho.commons.launcher.Launcher.main(Launcher.java:92)

cdeptula commented 9 years ago

To fix this change the following lines in JdbcMetaDataDialog: (Lines 332-335)

if (outputField.length == 0) continue; tableItem.setText(1, outputField[0]); if (outputField.length == 1) continue; tableItem.setText(2, outputField[1]);

to:

if (outputField.length == 0) continue; tableItem.setText(1, Const.NVL(outputField[0],"")); if (outputField.length == 1) continue; tableItem.setText(2, Const.NVL(outputField[1],""));

rpbouman commented 9 years ago

@cdeptula thank you! Would you mind sending me a pull request? I'll happily accept it.

rpbouman commented 9 years ago

@cdeptula ok - I made the suggested changes but I still experienced a NPE in case output fields weren't configured. Fixed that too.

https://github.com/rpbouman/pentaho-pdi-plugin-jdbc-metadata/commit/f10902720384828b5367d80533ecb28d85aa76ce

Will close since this is fixed in master. Will take a while before I bump the version for the marketplace.

cdeptula commented 9 years ago

Thanks @rpbouman. I was playing around with Issue #2 adding the Kettle Data Type to the output columns and did not have a clean branch to commit this fix to and then create the pull request.

The Const.NVL should have worked as it should do the same thing that your code does. It is a built in utility function in Pentaho. Anyway whenever assigning a value to a String field in the dialog it is a best practice to replace nulls with empty strings.

rpbouman commented 9 years ago

@cdeptula Have you tried if this solves your issue? Please re-open this issue if you're still experiencing a problem.

cdeptula commented 9 years ago

Yes I tested it and it worked. I am just surprised the Const.NVL did not work for you. It does not matter though.

rpbouman commented 9 years ago

@cdeptula Const.NVL probably works for me but I thought it would be better not to depend on it since the straight up java code works just as well and will work always. Keeping the issue closed you verified it works for you.