craigmcc    2002/07/17 08:40:23

  Modified:    .        STATUS
               src/share/org/apache/struts/action DynaActionForm.java
  Log:
  Improve the exception message you get when the property type specified
  in a <form-property> element is invalid.  Thanks to James Turner for the
  patch!
  
  PR: Bugzilla #10881
  Submitted by: James Turner <turner at blackbear.com>
  
  Revision  Changes    Path
  1.26      +1 -2      jakarta-struts/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/STATUS,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- STATUS    17 Jul 2002 11:24:08 -0000      1.25
  +++ STATUS    17 Jul 2002 15:40:23 -0000      1.26
  @@ -42,7 +42,6 @@
   Standard Actions:
   ----------------
   10322 Problems with LookupDispatchAction and other locales
  -10881 PATCH: DynaActionForm throws unhelpful NPE on invalid form-property type
   
   
   Tiles Framework:
  
  
  
  1.3       +16 -4     
jakarta-struts/src/share/org/apache/struts/action/DynaActionForm.java
  
  Index: DynaActionForm.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/DynaActionForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DynaActionForm.java       18 Jan 2002 03:46:52 -0000      1.2
  +++ DynaActionForm.java       17 Jul 2002 15:40:23 -0000      1.3
  @@ -198,6 +198,8 @@
        *
        * @exception IllegalArgumentException if there is no property
        *  of the specified name
  +     * @exception NullPointerException if the type specified for the
  +     *  property is invalid
        */
       public Object get(String name) {
   
  @@ -209,6 +211,10 @@
   
           // Return a null value for a non-primitive property
           Class type = getDynaProperty(name).getType();
  +        if (type == null) {
  +            throw new NullPointerException
  +                ("The type for property " + name + " is invalid");
  +        }
           if (!type.isPrimitive()) {
               return (value);
           }
  @@ -349,12 +355,18 @@
        *  converted to the type required for this property
        * @exception IllegalArgumentException if there is no property
        *  of the specified name
  +     * @exception NullPointerException if the type specified for the
  +     *  property is invalid
        * @exception NullPointerException if an attempt is made to set a
        *  primitive property to null
        */
       public void set(String name, Object value) {
   
           DynaProperty descriptor = getDynaProperty(name);
  +        if (descriptor.getType() == null) {
  +            throw new NullPointerException
  +                ("The type for property " + name + " is invalid");
  +        }
           if (value == null) {
               if (descriptor.getType().isPrimitive()) {
                   throw new NullPointerException
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to