Uploaded image for project: 'Pivot'
  1. Pivot
  2. PIVOT-987

Different handling of script return values in BXMLSerializer

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1, 2.0.5
    • Component/s: core-serialization
    • Labels:
      None
    • Environment:
      All

      Description

      In my bxml, I defined a TextInputContentListener method for previewInsertText in script. The method was getting invoked, but my returned Vote seemed to get ignored. Stepping through the code, I found that BXMLSerializer never assigns the result variable and ignores the returned value when the method is specified as an attribute but not when it's a child element. Is there a reason for this, or is this a bug?

      I'm using 2.0.4, but the same code is in trunk

      BXMLSerializer:

      inner class AttributeInvocationHandler, method invoke(Object proxy, Method method, Object[] args)
      ....
      // If the function didn't return a value, return the default
      Class<?> returnType = method.getReturnType();
      if (returnType == Vote.class)

      { result = Vote.APPROVE; }

      else if (returnType == Boolean.TYPE)

      { result = false; }

      return result;

      inner class ElementInvocationHandler, method invoke(Object proxy, Method method, Object[] args)
      .....
      // If the function didn't return a value, return the default
      if (result == null) {
      Class<?> returnType = method.getReturnType();
      if (returnType == Vote.class)

      { result = Vote.APPROVE; }

      else if (returnType == Boolean.TYPE)

      { result = false; }

      }

      return result;

      1. 987.patch
        1 kB
        Roger Whitcomb

        Activity

        Hide
        rwhitcomb Roger Whitcomb added a comment -

        Attaching "987.patch" as what I think the fix should be.

        Josh, can you please verify that this patch is what you expect to see? If so, I will check in and you can pull the 2.0.x branch and test. (The patch file is for "trunk", but the code changes are exactly the same for the 2.0.x branch).

        Show
        rwhitcomb Roger Whitcomb added a comment - Attaching "987.patch" as what I think the fix should be. Josh, can you please verify that this patch is what you expect to see? If so, I will check in and you can pull the 2.0.x branch and test. (The patch file is for "trunk", but the code changes are exactly the same for the 2.0.x branch).
        Hide
        rwhitcomb Roger Whitcomb added a comment -

        Per separate email from Josh that these changes are what he would expect, I have committed the change to "trunk":
        Sending core/src/org/apache/pivot/beans/BXMLSerializer.java
        Transmitting file data .
        Committed revision 1740570.

        Merged also into "branches/2.0.x":
        Sending .
        Sending core/src/org/apache/pivot/beans/BXMLSerializer.java
        Transmitting file data .
        Committed revision 1740574.

        (Note: this also includes the earlier change in "trunk" to return Boolean.FALSE instead of "false" in the boolean return value case).

        So, Josh, can you pull the 2.0.x branch and rebuild and test in your application? I don't have a test case in front of me, but I believe this should resolve your issue. But if not, can you let us know?!

        Thanks.

        Show
        rwhitcomb Roger Whitcomb added a comment - Per separate email from Josh that these changes are what he would expect, I have committed the change to "trunk": Sending core/src/org/apache/pivot/beans/BXMLSerializer.java Transmitting file data . Committed revision 1740570. Merged also into "branches/2.0.x": Sending . Sending core/src/org/apache/pivot/beans/BXMLSerializer.java Transmitting file data . Committed revision 1740574. (Note: this also includes the earlier change in "trunk" to return Boolean.FALSE instead of "false" in the boolean return value case). So, Josh, can you pull the 2.0.x branch and rebuild and test in your application? I don't have a test case in front of me, but I believe this should resolve your issue. But if not, can you let us know?! Thanks.
        Hide
        rwhitcomb Roger Whitcomb added a comment -

        I'm going to close the issue, assuming that everything is okay.

        Feel free to reopen if there are further problems.

        Show
        rwhitcomb Roger Whitcomb added a comment - I'm going to close the issue, assuming that everything is okay. Feel free to reopen if there are further problems.

          People

          • Assignee:
            rwhitcomb Roger Whitcomb
            Reporter:
            joshhighley Josh Highley
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development