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

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: BeanUtils2
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: