I just fixed a bug in my application and the circumstances under which the bug has occurred (or better has been noticed) are really strange and maybe someone here can give me a hint to understand it.
First of all the bug itself was pretty dump because I have done a businessObject.getId() == this.currentBo.getId() check on client side and both instances have been loaded from the server (GWT RPC). So both instances are different (deserialization) and it should be an equals check (must have been late).
The curious thing is that the instance check has worked for me in my development environment (hosted mode as well as compiled)!! So I thought everything is fine with my code and I deployed to production and then the bug occurs (the instance check always returns false). There is no difference between my development environment and the production environment except the data stored in the database (test data vs. real data).
So I have copied production data to my development database and then the bug also occurs in development environment! I know it sounds pretty silly and I am sure the reason is not the actual data but maybe its part of it.
So I have done some logging and it turns out that the Long instances returned by getId() can be the same although the businessObject instances are different.
So basically:
1.) businessObject == this.currentBo returns false
2.) businessObject.equals(this.currentBo) returns true
3.) businessObject.getId() == this.currentBo.getId() returns true (this should return false!)
The id itself can only be set via the BusinessObject's constructor, so its immutable.
Does anyone have an idea how this can happen? As the BusinessObjects instances are created by deserializing the GWT RPC payload I thought that every instance is different. How can it happen that Long instances are the same? I do not have any idea that would help me to understand what has happened.
-- J.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/bAJy30kYUf8J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment