javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2542

h:commandButton targeted action method throwing Exception is called twice in composite component

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.13, 2.1.19
    • Fix Version/s: 2.2.4
    • Component/s: composite components
    • Labels:
      None
    • Environment:

      Glassfish 3.1.2.2

      Description

      If a composite component uses an action method attribute that throws an exception at runtime and is targeted at a h:commandButton the action method is executed twice. This usually has undesirable side effects, because even though a business transaction terminated unexpectedly it may run two times.

      To reproduce run the attached project and observe the difference between clicking on the "Normal button" and the "Composite button". In the first case the message "test() executed" is echoed to the output once, in the second case twice.

      1. changebundle.txt
        2 kB
        Manfred Riem
      2. compositeaction.tar.bz2
        3 kB
        frederickkaempfer

        Issue Links

          Activity

          Hide
          Ed Burns added a comment -

          Thanks for attaching a reproducer. That makes it easier for us to fix.

          Show
          Ed Burns added a comment - Thanks for attaching a reproducer. That makes it easier for us to fix.
          Hide
          frederickkaempfer added a comment -

          FYI upon further inspection it looks like the "special excaption handling" code in ContextualCompositeMethodExpression#invoke is responsible for the action method being called twice. So the first time

          return delegate.invoke(elContext, objects);

          invokes the method and the second time

          return ((MethodExpression) fallback).invoke(elContext, objects);

          I'm not sure under which "CC nesting" circumstances the second invoke is required, but perhaps it helps you debug the issue and narrow down the case where it is necessary.

          Thanks.

          Show
          frederickkaempfer added a comment - FYI upon further inspection it looks like the "special excaption handling" code in ContextualCompositeMethodExpression#invoke is responsible for the action method being called twice. So the first time return delegate.invoke(elContext, objects); invokes the method and the second time return ((MethodExpression) fallback).invoke(elContext, objects); I'm not sure under which "CC nesting" circumstances the second invoke is required, but perhaps it helps you debug the issue and narrow down the case where it is necessary. Thanks.
          Hide
          Manfred Riem added a comment -

          Can you verify if this is still an issue with the latest 2.1 release?

          Show
          Manfred Riem added a comment - Can you verify if this is still an issue with the latest 2.1 release?
          Hide
          frederickkaempfer added a comment -

          Yes the issue still exists. I have tried the reproducer with 2.1.19 and the composite action method throwing an exception is still called 2 times.

          Show
          frederickkaempfer added a comment - Yes the issue still exists. I have tried the reproducer with 2.1.19 and the composite action method throwing an exception is still called 2 times.
          Hide
          Manfred Riem added a comment -

          Applied to 2.2 branch,

          svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES-2542, r=rogerk, make sure we only do the other logic in ContextualCompositeComponentMethodExpression if the exception was a MethodNotFoundException."
          Sending jsf-ri\src\main\java\com\sun\faces\facelets\el\ContextualCompositeMethodExpression.java
          Transmitting file data .
          Committed revision 12539.

          Show
          Manfred Riem added a comment - Applied to 2.2 branch, svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES-2542 , r=rogerk, make sure we only do the other logic in ContextualCompositeComponentMethodExpression if the exception was a MethodNotFoundException." Sending jsf-ri\src\main\java\com\sun\faces\facelets\el\ContextualCompositeMethodExpression.java Transmitting file data . Committed revision 12539.
          Hide
          Neil Griffin added a comment -

          Manfred informed me that this fix has been backported to the 2.1 branch.

          For those interested, please do us all a favor and test the 2.1.27-SNAPSHOT release from the snapshot repository:
          https://maven.java.net/content/repositories/snapshots/com/sun/faces/

          ... and let us know if it is working. Thanks!

          Show
          Neil Griffin added a comment - Manfred informed me that this fix has been backported to the 2.1 branch. For those interested, please do us all a favor and test the 2.1.27-SNAPSHOT release from the snapshot repository: https://maven.java.net/content/repositories/snapshots/com/sun/faces/ ... and let us know if it is working. Thanks!
          Hide
          frederickkaempfer added a comment -

          Thanks for the fix. I tried the reproducer with 2.1.27-SNAPSHOT and the method is indeed only executed once.

          Show
          frederickkaempfer added a comment - Thanks for the fix. I tried the reproducer with 2.1.27-SNAPSHOT and the method is indeed only executed once.
          Hide
          Neil Griffin added a comment -

          Thanks for letting us know that it is working!

          Show
          Neil Griffin added a comment - Thanks for letting us know that it is working!

            People

            • Assignee:
              Manfred Riem
              Reporter:
              frederickkaempfer
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: