You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Tomas Viberg <to...@viberg.nu> on 2002/05/26 19:17:48 UTC

[PATCH][BeanUtils] NoSuchMethod for read only properties and NullPointer when populating primitives

Comments, anyone?

Regards
/ Tomas


----- Original Message ----- 
From: Tomas Viberg 
To: commons-dev@jakarta.apache.org 
Sent: Sunday, May 19, 2002 7:29 PM
Subject: [PATCH] BeanUtils - read only properties and null value conversion


Hello,

I humbly submit a patch for BeanUtils.java, correcting the following errors:

1. When you try to populate a read-only property, the populate method throws a NoSuchMethodException (wrapped in an InvocationTargetException), since there is no check that the property has a setter method.

2. When you try to populate a primitive property with a null value, you get a NullPointerException, since no data type conversion is applied to null values. 

I have also patched BeanUtilsTestCase.java to include setting a primitive property to null and attempting to set a read-only (simple) property.

Regards,
Tomas Viberg, tomas@viberg.nu



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>

Re: [PATCH][BeanUtils] NoSuchMethod for read only properties and NullPointer when populating primitives

Posted by robert burrell donkin <ro...@mac.com>.
(after a bit of consideration) i've now committed this patch.

this isn't really a bit of beanutils i've been heavily involved with, so 
if anyone has strong opinions that it this is wrong, i won't be upset if 
they want to fix it in some other way.

- robert


On Sunday, May 26, 2002, at 06:17 PM, Tomas Viberg wrote:

> Comments, anyone?
>
> Regards
> / Tomas
>
>
> ----- Original Message -----
> From: Tomas Viberg
> To: commons-dev@jakarta.apache.org
> Sent: Sunday, May 19, 2002 7:29 PM
> Subject: [PATCH] BeanUtils - read only properties and null value 
> conversion
>
>
> Hello,
>
> I humbly submit a patch for BeanUtils.java, correcting the following 
> errors:
>
> 1. When you try to populate a read-only property, the populate method 
> throws a NoSuchMethodException (wrapped in an InvocationTargetException), 
> since there is no check that the property has a setter method.
>
> 2. When you try to populate a primitive property with a null value, you 
> get a NullPointerException, since no data type conversion is applied to 
> null values.
>
> I have also patched BeanUtilsTestCase.java to include setting a primitive 
> property to null and attempting to set a read-only (simple) property.
>
> Regards,
> Tomas Viberg, tomas@viberg.nu
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>
>   --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PATCH][BeanUtils] NoSuchMethod for read only properties and NullPointer when populating primitives

Posted by robert burrell donkin <ro...@mac.com>.
hi Tomas

i've taken a look at the patches and - at first glance - i like what i see.

but...

i'm a bit reluctant to change anything in this part of beanutils without 
the ok from craig - but he's pretty busy at the moment.

so...

i'll leave it a couple of days before i take any action. that way, anyone 
who wants to say something has the chance to do so. (this will also give 
me the chance to make sure i haven't missed anything.)

- robert

On Sunday, May 26, 2002, at 06:17 PM, Tomas Viberg wrote:

> Comments, anyone?
>
> Regards
> / Tomas
>
>
> ----- Original Message -----
> From: Tomas Viberg
> To: commons-dev@jakarta.apache.org
> Sent: Sunday, May 19, 2002 7:29 PM
> Subject: [PATCH] BeanUtils - read only properties and null value 
> conversion
>
>
> Hello,
>
> I humbly submit a patch for BeanUtils.java, correcting the following 
> errors:
>
> 1. When you try to populate a read-only property, the populate method 
> throws a NoSuchMethodException (wrapped in an InvocationTargetException), 
> since there is no check that the property has a setter method.
>
> 2. When you try to populate a primitive property with a null value, you 
> get a NullPointerException, since no data type conversion is applied to 
> null values.
>
> I have also patched BeanUtilsTestCase.java to include setting a primitive 
> property to null and attempting to set a read-only (simple) property.
>
> Regards,
> Tomas Viberg, tomas@viberg.nu
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>
>   --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>