Uploaded image for project: 'Commons Sandbox'
  1. Commons Sandbox
  2. SANDBOX-371

[BeanUtils2] Make sure that a property is readable in DefaultBeanAccessor.getProperty( String name )

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • BeanUtils2
    • None

    Description

      Problem: The following statement in line 50 in DefaultBeanAccessor may cause a NullPointerException, because getReadMethod() will return null, if no getter for the property is present:

      Object newBean = propertyDescriptor.getReadMethod().invoke( bean ); 

      Solution: throw a NoSuchMethodException, if the property is write only.

      if ( propertyDescriptor.getReadMethod() == null )
      {
          throw new NoSuchMethodException( String.format( "Bean of type %s does not provide a getter for property '%s'!",
                                                       bean.getClass().getName(), name ) );
      }

      Attachments

        1. SANDBOX-371.txt
          3 kB
          Benedikt Ritter

        Activity

          People

            simone.tripodi Simone Tripodi
            britter Benedikt Ritter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: