Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2624

MethodGetAndSet.setValue uses wrong source to determine which type to convert to when there's no setter

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.4
    • 1.4.6, 1.5-M1
    • wicket
    • None

    Description

      MethodGetAndSet.setValue uses wrong source to determine which type to convert to when there's no setter, resulting in exceptions like this:
      org.apache.wicket.WicketRuntimeException: Error setting field: private int PropertyResolverTest$DirectFieldSetWithDifferentTypeThanGetter.value on object: PropertyResolverTest$DirectFieldSetWithDifferentTypeThanGetter@396477d9
      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1150)
      at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:588)
      at org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)
      at PropertyResolverTest.testDirectFieldSetWithDifferentTypeThanGetter(PropertyResolverTest.java:12)

      Bug is located in:
      converted = converter.convert(value, getMethod.getReturnType());

      Instead, it should read:
      converted = converter.convert(value, type);

      Testcase attached.

      Additional thoughts:
      if (setMethod != null)
      {
      type = getMethod.getReturnType();
      }
      This is really confusing (we check setMethod presence but get type from getMethod). Luckily, this works as expected because in MethodGetAndSet.findSetter only methods with same (or superclass) type as getter are returned.

      Attachments

        Activity

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

          People

            jdonnerstag Juegen Donnerstag
            slonopotamus Marat Radchenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment