2011/10/5 Tim Funk <funk...@apache.org>:
> I'm a little confused. On a quick glance of the method ... it appears the
> method setProperty should be returning true if it did something, and false
> if not. This would mean the cast is not needed (actually wrong).

We are calling a method that returns boolean, and cast is needed to
convert returned object to Boolean.

My change is that this Boolean should be unboxed to return boolean,
and it is better to do this unboxing explicitly.

> The fact
> that the method did NOT throw an exception should mean that we should return
> true. So we end up with:
>
>    setPropertyMethodBool.invoke(o, params);
>    return true;

There are the following lines below, that deal with methods that do
not return "boolean":

375                     setPropertyMethodVoid.invoke(o, params);
376                     return true;

When a property is not found, "setProperty(): boolean" methods in our
code do not throw an exception, but return false.

I do not know why it is so, but maybe when this feature was
implemented for Tomcat 6 (r565464) this was a way to align with some
old code. Also throwing an exception is a bit more expensive than
returning false.

http://svn.apache.org/viewvc?diff_format=l&view=revision&revision=565464

Best regards,
Konstantin Kolinko

> On Wed, Oct 5, 2011 at 11:44 AM, <kkoli...@apache.org> wrote:
>
>> Author: kkolinko
>> Date: Wed Oct  5 15:44:58 2011
>> New Revision: 1179274
>>
>> URL: http://svn.apache.org/viewvc?rev=1179274&view=rev
>> Log:
>> Resolve a warning about unboxing operation. Perform unboxing explicitly.
>>
>> Modified:
>>    tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
>>
>> Modified: tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
>> URL:
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java?rev=1179274&r1=1179273&r2=1179274&view=diff
>>
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
>> (original)
>> +++ tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java Wed
>> Oct  5 15:44:58 2011
>> @@ -359,7 +359,8 @@ public final class IntrospectionUtils {
>>                 params[1] = value;
>>                 if (setPropertyMethodBool != null) {
>>                     try {
>> -                        return (Boolean) setPropertyMethodBool.invoke(o,
>> params);
>> +                        return ((Boolean) setPropertyMethodBool.invoke(o,
>> +                                params)).booleanValue();
>>                     }catch (IllegalArgumentException biae) {
>>                         //the boolean method had the wrong
>>                         //parameter types. lets try the other
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to