Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4149

No easy way to have an empty interceptor stack if have default stack

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.15.1
    • Fix Version/s: 2.5.12
    • Component/s: Core Interceptors
    • Labels:
      None

      Description

      If you have an action that you don't want to have any interceptors, if there is a defaultStack defined, you can't.

      My work around was to create an NoOpInterceptor that did nothing, and then declare interceptor stack that just included it to use.

      It used to be that you couldn't include an empty interceptor stack at all. That seems to not blow up now, but unfortunately it appears that it is treated as if it doesn't exist, and the defaultStack is used instead.

      I think a declared interceptor stack on an action should override the default, even if it is empty.

      Could then also provide an "emptyStack" interceptor in struts-default.xml that people could use when they wanted this behavior.

        Activity

        Hide
        lukaszlenart Lukasz Lenart added a comment -

        I think you must have very specific case when to use an empty stack - basically the whole Struts logic is based on interceptors.

        Show
        lukaszlenart Lukasz Lenart added a comment - I think you must have very specific case when to use an empty stack - basically the whole Struts logic is based on interceptors.
        Hide
        perfnorm Jasper Rosenberg added a comment -

        I actually use an empty stack a ton. Pretty much anytime we have a view that doesn't look at query parameters (but is still dynamic because the user may be logged in, etc), I use an empty stack since it is just overhead at that point.

        Show
        perfnorm Jasper Rosenberg added a comment - I actually use an empty stack a ton. Pretty much anytime we have a view that doesn't look at query parameters (but is still dynamic because the user may be logged in, etc), I use an empty stack since it is just overhead at that point.
        Hide
        lukaszlenart Lukasz Lenart added a comment -

        Ok, but I think this change is a bit intrusive (DTD has to be changed) - I'm going to postpone it till 2.5

        Show
        lukaszlenart Lukasz Lenart added a comment - Ok, but I think this change is a bit intrusive (DTD has to be changed) - I'm going to postpone it till 2.5
        Hide
        perfnorm Jasper Rosenberg added a comment -

        Makes sense, there is also an easy workaround.

        Show
        perfnorm Jasper Rosenberg added a comment - Makes sense, there is also an easy workaround.
        Hide
        lukaszlenart Lukasz Lenart added a comment -

        I was trying to figure out a possible solution and right now an empty stack (with no interceptors) is treated as non-existing stack and Struts will fallback to <default-interceptor-ref/> (because a list of interceptors has size 0).

        I think there is no easy way to avoid the fallback, except declaring an empty stack with the NoOp interceptor directly in struts-default.xml

        Show
        lukaszlenart Lukasz Lenart added a comment - I was trying to figure out a possible solution and right now an empty stack (with no interceptors) is treated as non-existing stack and Struts will fallback to <default-interceptor-ref/> (because a list of interceptors has size 0). I think there is no easy way to avoid the fallback, except declaring an empty stack with the NoOp interceptor directly in struts-default.xml
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 8f75e1a19dfde5b55bb3265737d81c8bfa8ccb39 in struts's branch refs/heads/master from Lukasz Lenart
        [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=8f75e1a ]

        WW-4149 Introduces an empty stack

        Show
        jira-bot ASF subversion and git services added a comment - Commit 8f75e1a19dfde5b55bb3265737d81c8bfa8ccb39 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=8f75e1a ] WW-4149 Introduces an empty stack
        Hide
        lukaszlenart Lukasz Lenart added a comment -

        Introduced an empty stack using the NoOpInterceptor https://cwiki.apache.org/confluence/display/WW/NoOp+Interceptor

        Show
        lukaszlenart Lukasz Lenart added a comment - Introduced an empty stack using the NoOpInterceptor https://cwiki.apache.org/confluence/display/WW/NoOp+Interceptor
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Jenkins build Struts-JDK7-master #624 (See https://builds.apache.org/job/Struts-JDK7-master/624/)
        WW-4149 Introduces an empty stack (lukaszlenart: rev 8f75e1a19dfde5b55bb3265737d81c8bfa8ccb39)

        • (edit) core/src/main/resources/struts-default.xml
        • (add) core/src/main/java/org/apache/struts2/interceptor/NoOpInterceptor.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #624 (See https://builds.apache.org/job/Struts-JDK7-master/624/ ) WW-4149 Introduces an empty stack (lukaszlenart: rev 8f75e1a19dfde5b55bb3265737d81c8bfa8ccb39) (edit) core/src/main/resources/struts-default.xml (add) core/src/main/java/org/apache/struts2/interceptor/NoOpInterceptor.java

          People

          • Assignee:
            lukaszlenart Lukasz Lenart
            Reporter:
            perfnorm Jasper Rosenberg
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development