FYI -----Original Message----- From: Drew Davidson [mailto:[EMAIL PROTECTED] Sent: woensdag 24 september 2003 17:58 To: John D. Mitchell Cc: BOGAERT Mathias; '[EMAIL PROTECTED]' Subject: Re: Null vs. Empty
John D. Mitchell wrote: >>>>>>"BOGAERT" == BOGAERT Mathias <[EMAIL PROTECTED]> writes: >>>>>> >>>>>> >[...] > > > >>There is a serious blocking bug in OGNL (as reported here: >>http://jira.opensymphony.com/secure/ViewIssue.jspa?id=22373) which I >>need fixed asap. Is there some sort of CVS snapshot I could get to try >>out? >> >> > >I don't see OgnlValueStack in the online 2.6.3 Ognl documentation so I >can't easily check Drew's intent at the moment but I'm sure that Drew >will jump in on the OGNL specifics soon. > > There is no OgnlValueStack in OGNL. This must be an OpenSymphony artifact. >I'd like to point out that there's a big difference between something >that is NULL (i.e., it doesn't exist) versus something which exists but >is e.g., empty (e.g., ""). > >In general, IMO, if you put an empty string in then you should get an >empty string back out, *not* a NULL. > > I tend to agree with John here. An empty string is not null, nor should it be considered so in a general framework like OGNL. Your test: public void testSettingDogInteger() { OgnlValueStack vs = new OgnlValueStack(); Dog dog = new Dog(); vs.push(dog); vs.setValue("blah", ""); assertEquals(null, dog.getBlah()); } I assume that Dog is defined such that: public class Dog { public void setBlah(Integer value); public Integer getBlah(); } From the descriptions of the problem domain in your issue database it appears that you are binding values from a servlet request parameter into objects. Isn't there some controller that sits between OGNL and the eventual target that can filter empty strings to null? My old buddy Patrick Lightbody writes: "Yeah, I think that will work for now -- the real problem is Ognl has a bug such that if type conversion from X -> Y returns null, Ognl assumes it should use type X for the method call and not type Y. I'll open a bug with them." You are correct that the behaviour should be that if it attempts conversion for calling a method it should stick with that type for the actual call, even if the result is null. Do you have a good test of the failure of this method, Patrick? My dim recollection tells me that the current code should work correctly because OgnlRuntime is actually getting the signature of the "appropriate" method before attempting conversion, then using that same Method to do the call after the conversion. Any test cases that exemplify this would be appreciated. - Drew -- +---------------------------------+ < Drew Davidson | OGNL Technology > < Professional Open Source > +---------------------------------+ | Email: [EMAIL PROTECTED] / | Web: http://www.ognl.org / | Vox: (520) 531-1966 < | Fax: (520) 531-1965 \ | Mobile: (520) 405-2967 \ +---------------------------------+ ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork