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

MessageStorePreResultListener doesn't store messages for 3rd-party RedirectResult subclasses

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.28
    • Fix Version/s: 2.3.29, 2.5.1
    • Component/s: None
    • Labels:
      None

      Description

      My team uses a custom subclass of ServletRedirectResult, e.g. "org.tdar.struts.ServletRedirectResult". After updating to 2.3.8 our messages no longer survive a redirect. I believe the problem lies with this section of MessageStorePreResultListener:

      if (resultConfig != null) {
          isRedirect = ServletRedirectResult.class.getName().equals(resultConfig.getClassName())
                  || ServletActionRedirectResult.class.getName().equals(resultConfig.getClassName());
      }
      

      Per the discussion in WW-4605, the following change could likely resolve the issue:

      if (resultConfig != null) {
          isRedirect = ServletRedirectResult.class.isAssignableFrom(Class.forName(resultConfig.getClassName()));
      }
      

        Issue Links

          Activity

          Hide
          jtdevos Jim deVos added a comment -

          FYI: it looks like "major" is the default priority, but our team was able to work around the issue. So feel free to dial down.

          Show
          jtdevos Jim deVos added a comment - FYI: it looks like "major" is the default priority, but our team was able to work around the issue. So feel free to dial down.
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Can you share the workaround?

          Show
          lukaszlenart Lukasz Lenart added a comment - Can you share the workaround?
          Hide
          jtdevos Jim deVos added a comment -

          Sorry, I should have been more specific. Essentially are "workaround" amounted to reverting to using ServletRedirectResult instead of our custom subclass.

          After reviewing our action classes, we determined that only a handful of the actions that use action messages get called via a redirect. And of those few actions, none of them relied upon the extra functionality of our custom RedirectResult subclass. So we simply changed the result-type definition in struts.xml from "redirect" to "tdar-redirect", and updated our mappings so that the aforementioned actions used "redirect" results, and the rest used "tdar-redirect".

          Show
          jtdevos Jim deVos added a comment - Sorry, I should have been more specific. Essentially are "workaround" amounted to reverting to using ServletRedirectResult instead of our custom subclass. After reviewing our action classes, we determined that only a handful of the actions that use action messages get called via a redirect. And of those few actions, none of them relied upon the extra functionality of our custom RedirectResult subclass. So we simply changed the result-type definition in struts.xml from "redirect" to "tdar-redirect", and updated our mappings so that the aforementioned actions used "redirect" results, and the rest used "tdar-redirect".
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit f052398cd255f8fc2ff50cbd0f5828e62a0241a1 in struts's branch refs/heads/support-2-3 from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=f052398 ]

          WW-4618 Supports custom redirect types which base on ServletRedirectResult

          Show
          jira-bot ASF subversion and git services added a comment - Commit f052398cd255f8fc2ff50cbd0f5828e62a0241a1 in struts's branch refs/heads/support-2-3 from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=f052398 ] WW-4618 Supports custom redirect types which base on ServletRedirectResult
          Hide
          jira-bot ASF subversion and git services added a comment -

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

          WW-4618 Supports custom redirect types which base on ServletRedirectResult

          Show
          jira-bot ASF subversion and git services added a comment - Commit dbf744f54bbc7d8cebac1a0a8d52b15065a2c484 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=dbf744f ] WW-4618 Supports custom redirect types which base on ServletRedirectResult
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Struts-JDK6-support-2.3 #1027 (See https://builds.apache.org/job/Struts-JDK6-support-2.3/1027/)
          WW-4618 Supports custom redirect types which base on (lukaszlenart: rev f052398cd255f8fc2ff50cbd0f5828e62a0241a1)

          • core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Struts-JDK6-support-2.3 #1027 (See https://builds.apache.org/job/Struts-JDK6-support-2.3/1027/ ) WW-4618 Supports custom redirect types which base on (lukaszlenart: rev f052398cd255f8fc2ff50cbd0f5828e62a0241a1) core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Struts-JDK7-master #471 (See https://builds.apache.org/job/Struts-JDK7-master/471/)
          WW-4618 Supports custom redirect types which base on (lukaszlenart: rev dbf744f54bbc7d8cebac1a0a8d52b15065a2c484)

          • core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Struts-JDK7-master #471 (See https://builds.apache.org/job/Struts-JDK7-master/471/ ) WW-4618 Supports custom redirect types which base on (lukaszlenart: rev dbf744f54bbc7d8cebac1a0a8d52b15065a2c484) core/src/main/java/org/apache/struts2/interceptor/MessageStorePreResultListener.java

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              jtdevos Jim deVos
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development