Uploaded image for project: 'Commons Digester'
  1. Commons Digester
  2. DIGESTER-71

CallMethodRule rule can't be used to call no arg methods

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 8244

    Description

      The digester's CallMethodRule rule can't be used to call methods taking no
      argument. The main issue is the semantic of the constructor, a paramCount of 0
      doesn't stand for "no argument" but for "pass the tag body as argument", thus
      preventing the call of no arg methods on the parent objet.

      One could expect CallMethodRule to behave like Class.getMethod(), that is, a
      null or empty Class[] array means we are looking for a no argument method.
      Currently the decision is not made on the value of paramTypes but on the value
      of paramCount. If paramType is empty or null it's forced to an array with a
      single String.class element :

      in the constructor :

      if (paramTypes == null) {
      this.paramTypes = new Class[paramCount];

      and later in end() :

      if (paramTypes.length == 0)

      { paramTypes = new Class[1]; paramTypes[0] = "abc".getClass(); }

      Fixing this issue is just a matter of letting paramTypes untouched till the
      method.invoke() call.

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--tmp.txt
          2 kB
          Michael Marrotte
        2. ASF.LICENSE.NOT.GRANTED--Test5.xml
          0.4 kB
          Emmanuel Bourg
        3. ASF.LICENSE.NOT.GRANTED--CallMethodRule-noargfix.txt
          7 kB
          Emmanuel Bourg

        Activity

          People

            Unassigned Unassigned
            ebourg Emmanuel Bourg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: