Thursday, July 7, 2016

Getter method returning 'undefined' value while toString showing a correct object

Hi,

I am experiencing a very strange issue with reading value from an object retrieved through RPC (the object has default constructor, implements Serializable, and has only Double, Boolean, List<Double> and some enum-types fields inside - so all serializable).
I read the object on the client side and keep getting null or undefined value when I use getter on one of its fields - a Double, however, when I try to log the whole object, the field is displayed as a correct double value.
This is a fragment of my code:
this.sshParams = (BasicSSHParameters) retrievedObjectData;
log
.info("Params {}, lamb: {}, b: {}, mmin: {}", sshParams, sshParams.getLamb(), sshParams.getB(), sshParams.getMmin());
(we have a wrapper to add slf4j logging style to java.util.logging.Logger.getLogger(MyClass.class))

And what I get in the browser console is:
INFO: Params BasicSSHParameters([..], lamb=4.6872906724508825, [...], b=0.8669989980064977, mmin=0.6, [...]), lamb: undefined, b: undefined, mmin: 0.6
So it seems the same variable is correctly read within the toString() method, and incorrectly read using the getter. And, magically, another variable (mmin) is correctly read using both. I thought it might be issues of double precision, but when I changed lamb to be 4.687, it didn't change the behaviour. The name 'lamb' also shouldn't be any problem as the same happens with 'b'.

All the fields in BasicSSHParameters are final but we use the <set-property name="rpc.XserializeFinalFields" value="true" /> in our gwt.xml

To make the debugging worse, the problem doesn't happen always. On my local server instance it happens sometimes, and sometimes not (getLamb() then returns a proper double value), but for our team's development server it happens all the time.
We use GWT 2.8.0 (beta).

Has any of you ever experienced a similar problem? Or have any idea what might be happening?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment