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 )

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment