how to Handl nullPointerException in tFilterRow

Not applicable

how to Handl nullPointerException in tFilterRow

hi community,
if have a problem with a NullPointerException in tFilterRow
Error log:
Exception in component tFilterRow_1
java.lang.NullPointerException
at haltern.journalentwicklung_0_1.journalentwicklung.tFileInputDelimited_1Process(journalentwicklung.java:3547)
at haltern.journalentwicklung_0_1.journalentwicklung.runJobInTOS(journalentwicklung.java:4517)
at haltern.journalentwicklung_0_1.journalentwicklung.main(journalentwicklung.java:4385)

Job code:
3547: row1.column1.equals("X")
4517: tFileInputDelimited_1Process(globalMap);
4385: int exitCode = testjobClass.runJobInTOS(args);

the input of column1 is defined as String. The input can be "x" or "y" but it could be possible that some rows are null so I set column1 as Nullable. Should I add some code to the advanced
I use the advanced mode of tFilterRow: row1.column1.equals("X")
should i write more? Can you help me with the problem?
Regards,

Piero
One Star

Re: how to Handl nullPointerException in tFilterRow

Hi Piero,
It looks like your column1 is null. You could prevent this from happening by using a tMap in front of the tFilterRow where you map all columns with automap and change the column1 output to the following:
(!row1.column1 == null) ? row1.column1 : ""

Hope this helps.
Regards,
Arno
Not applicable

Re: how to Handl nullPointerException in tFilterRow

Hi Arno,
thank you very much for your help again!
I tried your code but it says now: The operator ! is not defined for the typ String
what should I do?
regards,
Piero
One Star

Re: how to Handl nullPointerException in tFilterRow

! Relational.ISNULL(row1.column1) ? row1.column1 : ""
One Star

Re: how to Handl nullPointerException in tFilterRow

Hi Piero,
I'm very sorry, my mistake. Janhess's code will work as will this code:
(row1.column1 != null) ? row1.column1 : ""

Regards,
Arno
Not applicable

Re: how to Handl nullPointerException in tFilterRow

Hi Arno and janhess,
Thank you very much. With the code the Job is working very well now Smiley Happy