Issue with code in a java snippet?

Hi,
While testing my workflows on our new Knime server v 4.6, I encountered a strange behavior of a piece of code in a java snippet. Java Experts will excuse my code but what was running as I expected under Knime server v4.3 does not produce the same results under v 4.6.
Below is the code which produces the expected results (workflow developed with the knime client v3.2.0):

The same code with Knime client 3.5.2 does not work. The code in the 1st part of the if statement is never executed. See screenshot below:

I got it fixed by changing the if statement to “if (c_Measurement == (int) v_valInf)” (the (-1) *(col x) has no effect).

Are you aware of this kind of issue? Could you tell me what has changed? Is this an expected behavior of the new Knime platform?
Thanks in advance for your help on this,
Regards,
Claire

Hi Claire,

don’t compare Object types (e.g. Integer) with ==, but always go for the equals method instead (this is a Java fundamental, nothing KNIME specific):

if (value1.equals(value2)) { … }

The nasty thing is, sometimes == might still work, e.g. when you have values which are cached internally. So, this might explain that your workflow performed as expected under certain circumstances.

Best,
Philipp

1 Like

Ok, thanks a lot Philipp.