Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-987

Groovy Beans Now Have More Flavor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-2
    • 1.0-JSR-3
    • None
    • None
    • OSX 10.4, JDK 1.4.2, BeanUtils. 1.6.1 & 1.7.0

    Description

      In JSR 1, it was possible to use the Jakarta Commons BeanUtils framework to "describe" groovy beans that included "get" methods that were not proper bean accessors. In JSR 2, this is no longer possible as the "get" methods are being executed. I don't believe this is a bug in BeanUtils, since the behavior changed with JSR 2.

      The Groovy class below illustrates this. I executed this class using the GroovyJ plugin in IDEA. The only additional dependency is the BeanUtils library (core in this case).

      Comment out method "getUnsafe()" to see the test case execute properly.

      ==========

      import org.apache.commons.beanutils.PropertyUtils;

      public class GroovyBean {
      @Property String test = "hi";
      @Property String there = "yo";

      public String getUnsafe(Object arg)

      { if (arg == null) throw new IllegalArgumentException("Null: arg"); return arg.toString(); }

      public static void main(String[] args) {
      try {
      GroovyBean bean = new GroovyBean();
      Map properties = PropertyUtils.describe(bean);
      properties.keySet().each()

      { property -> println property; }

      } catch (Throwable t)

      { t.printStackTrace(); }

      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            nyven Ron Lancaster
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: