0

I am getting an error message in Talend and it appears to be down to a having a 'NULL' value within my 'comments' field.

I currently have this expression row1.comments.replaceAll("\u0000", "") which has been working and the reason for having this in place is because I have some text which is spaced out (example T E S T).

However,the latest run has failed due to a 'NULL' appearing in the comments field and I don't think my job design knows how to handle this, as well as the removing the spaces from the 'comments' text.

This is the error message: Exception in component tMap_1 (FACT_test)

java.lang.NullPointerException: Cannot invoke "String.replaceAll(String, String)" because "row1.comments" is null

Is there anyway to get around this problem, please?

Skin
  • 9,085
  • 2
  • 13
  • 29
AJ_25
  • 39
  • 3
  • Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Mark Rotteveel Apr 26 '23 at 12:23

1 Answers1

0

There's a little bit of information missing from your question (like what component are you using?) but regardless, you can check for null and deal with it accordingly using a ternary operator, something like this should work ...

row1.comments == null ? "" : row1.comments.replaceAll("\u0000", "")
Skin
  • 9,085
  • 2
  • 13
  • 29