tMap strange null pointer error

Forteen Stars

tMap strange null pointer error

Hi all,

 

just maybe somebody meets with similar case:

 

Source structure:

Screen Shot 2019-06-06 at 12.10.47 AM.png

 

 

Next tMap code, works as expected:

row1.event.equals("TEXT")?
null
:row1.validAfter==null?
null
:Long.valueOf(TalendDate.formatDate("yyyyMMddHH",row1.validAfter) ) 

but similar extended construction:

row1.event.equals("TEXT")?
null
:row1.isPermanent==1L?
-1L
:row1.validUntil==null?
null
:Long.valueOf(TalendDate.formatDate("yyyyMMddHH",row1.validUntil) ) 

not!

 

each part of wrong code work fine, and current solution - 

replaced by SQL CASE at source for validUntil:

row1.event.equals("TEXT")?
null

tMap for out.validUntil_Long

row1.validUntil==null?
null
:Long.valueOf(TalendDate.formatDate("yyyyMMddHH",row1.validUntil) ) 

tjavaRow

if (row1.isPermanent==1L) {
out.validUntil_Long = -1L;
}

3 step work as expected, but all together - not

 

Java 8, Windows

 

 

solutions it work well, just interesting - why? is it an error in the my IF code, error in talend or java version specific issue?

regards, Vlad

 

-----------
Tags (1)
Community Manager

Re: tMap strange null pointer error

I can't see anything immediately obvious I'm afraid. The only thing that looks like it might lead to a null pointer exception is the row1.event.equals("TEXT") code. However, your working solution has this as well.

Forteen Stars

Re: tMap strange null pointer error

I will test it later, what source of error - mix of types or construction

 

I have multi conditions constructions for string only and all work as expected

 

at the same time I have working constriction like:

condition?
(condition? (condition? true : false) : false)
:(condition? true : (condition? true : false))

and it works with different types

 

so need to find a time and simulate test cases 

 

Thank you for the answer Richard!

 

-----------
Three Stars

Re: tMap strange null pointer error

Thank for answer

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog