Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-443

PropertyUtils.setProperty(...) cannot find the Setter method if returnValue doesn't exact match the interface return value.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • 1.8.3
    • 2.0.0
    • Bean / Property Utils
    • None
    • at least Java 1.6.0_33 on ubuntu

    Description

      Here is My testClass:

      PropertyUtilsSetValueUTest.java
      import org.apache.commons.beanutils.PropertyUtils;
      import org.junit.Test;
      
      public class PropertyUtilsSetValueUTest {
      
          @Test
          public void testSetProperty() throws Exception {
              final MyEntity entity = new MyEntity();
      
              // fist set value manual
              final OtherEntity otherEntity = new OtherEntity();
              entity.setOtherEntity(otherEntity);
      
              // second set value with PropertyUtils
              PropertyUtils.setProperty(entity, "otherEntity", otherEntity);
              // => java.lang.NoSuchMethodException: Property 'otherEntity' has no setter method in class '... MyEntity'
      
          }
      
          public static class MyEntity implements MyEntityInterface {
              private OtherEntity otherEntity;
      
              @Override
              public OtherEntity getOtherEntity() {
                  return this.otherEntity;
              }
      
              public void setOtherEntity(final OtherEntity otherEntity) {
                  this.otherEntity = otherEntity;
              }
      
          }
      
          public static class OtherEntity implements OtherEntityInterface {
      
          }
      
          public static interface MyEntityInterface {
              OtherEntityInterface getOtherEntity();
          }
      
          public static interface OtherEntityInterface {
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            brabenetz Harald Brabenetz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: