Tapestry 5
  1. Tapestry 5
  2. TAP5-258

RequestPageCache should canonicalize page name

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.15
    • Fix Version/s: 5.0.16
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

      For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

      This could lead to loss of activation parameter. Example:

      Index.java:

      ...
      @Property(write = false)
      @PageActivationContext(activate = false)
      private Integer orderId;
      ...

      Index.tml:

      ...
      <t:pagelink t:page="orders/index">Broken link</t:pagelink>
      <t:pagelink t:page="orders">Correct link<t:pagelink>
      ...

      If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

      The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

      public static RequestPageCache decorateRequestPageCache(
      Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
      String serviceId, final ComponentClassResolver resolver) {
      return new RequestPageCache() {
      public Page get(String logicalPageName)

      { return delegate.get(resolver.canonicalizePageName(logicalPageName)); }

      };
      }

        Activity

        Ivan Dubrov created issue -
        Ivan Dubrov made changes -
        Field Original Value New Value
        Description Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

        For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

        This could lead to loss of activation parameter. Example:

        Index.java:

        {code:java}
        ...
        @Property(write = false)
        @PageActivationContext(activate = false)
        private Integer orderId;
        ...
        {code}

        Index.tml:

        {code:xml}
        ...
        <t:pagelink t:page="orders/index">Broken link</t:pagelink>
        <t:pagelink t:page="orders">Correct link<t:pagelink>
        ...
        {code}

        If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

        The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

        {code:java}
        public static RequestPageCache decorateRequestPageCache(
        Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
        String serviceId, final ComponentClassResolver resolver) {
        return new RequestPageCache() {
        public Page get(String logicalPageName) {
        return delegate.get(resolver.canonicalizePageName(logicalPageName));
        }
        };
        }
        {code}
        Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

        For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

        This could lead to loss of activation parameter. Example:

        Index.java:

        {code}
        ...
        @Property(write = false)
        @PageActivationContext(activate = false)
        private Integer orderId;
        ...
        {code}

        Index.tml:

        {code:xml}
        ...
        <t:pagelink t:page="orders/index">Broken link</t:pagelink>
        <t:pagelink t:page="orders">Correct link<t:pagelink>
        ...
        {code}

        If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

        The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

        {code:java}
        public static RequestPageCache decorateRequestPageCache(
        Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
        String serviceId, final ComponentClassResolver resolver) {
        return new RequestPageCache() {
        public Page get(String logicalPageName) {
        return delegate.get(resolver.canonicalizePageName(logicalPageName));
        }
        };
        }
        {code}
        Ivan Dubrov made changes -
        Description Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

        For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

        This could lead to loss of activation parameter. Example:

        Index.java:

        {code}
        ...
        @Property(write = false)
        @PageActivationContext(activate = false)
        private Integer orderId;
        ...
        {code}

        Index.tml:

        {code:xml}
        ...
        <t:pagelink t:page="orders/index">Broken link</t:pagelink>
        <t:pagelink t:page="orders">Correct link<t:pagelink>
        ...
        {code}

        If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

        The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

        {code:java}
        public static RequestPageCache decorateRequestPageCache(
        Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
        String serviceId, final ComponentClassResolver resolver) {
        return new RequestPageCache() {
        public Page get(String logicalPageName) {
        return delegate.get(resolver.canonicalizePageName(logicalPageName));
        }
        };
        }
        {code}
        Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

        For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

        This could lead to loss of activation parameter. Example:

        Index.java:

        <code>
        ...
        @Property(write = false)
        @PageActivationContext(activate = false)
        private Integer orderId;
        ...
        </code>

        Index.tml:

        {code:xml}
        ...
        <t:pagelink t:page="orders/index">Broken link</t:pagelink>
        <t:pagelink t:page="orders">Correct link<t:pagelink>
        ...
        {code}

        If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

        The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

        {code:java}
        public static RequestPageCache decorateRequestPageCache(
        Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
        String serviceId, final ComponentClassResolver resolver) {
        return new RequestPageCache() {
        public Page get(String logicalPageName) {
        return delegate.get(resolver.canonicalizePageName(logicalPageName));
        }
        };
        }
        {code}
        Ivan Dubrov made changes -
        Description Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

        For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

        This could lead to loss of activation parameter. Example:

        Index.java:

        <code>
        ...
        @Property(write = false)
        @PageActivationContext(activate = false)
        private Integer orderId;
        ...
        </code>

        Index.tml:

        {code:xml}
        ...
        <t:pagelink t:page="orders/index">Broken link</t:pagelink>
        <t:pagelink t:page="orders">Correct link<t:pagelink>
        ...
        {code}

        If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

        The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

        {code:java}
        public static RequestPageCache decorateRequestPageCache(
        Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
        String serviceId, final ComponentClassResolver resolver) {
        return new RequestPageCache() {
        public Page get(String logicalPageName) {
        return delegate.get(resolver.canonicalizePageName(logicalPageName));
        }
        };
        }
        {code}
        Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

        For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

        This could lead to loss of activation parameter. Example:

        Index.java:

        ...
        @Property(write = false)
        @PageActivationContext(activate = false)
        private Integer orderId;
        ...

        Index.tml:

        ...
        <t:pagelink t:page="orders/index">Broken link</t:pagelink>
        <t:pagelink t:page="orders">Correct link<t:pagelink>
        ...

        If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

        The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

        public static RequestPageCache decorateRequestPageCache(
        Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
        String serviceId, final ComponentClassResolver resolver) {
        return new RequestPageCache() {
        public Page get(String logicalPageName) {
        return delegate.get(resolver.canonicalizePageName(logicalPageName));
        }
        };
        }
        Howard M. Lewis Ship made changes -
        Assignee Howard M. Lewis Ship [ hlship ]
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Howard M. Lewis Ship made changes -
        Fix Version/s 5.0.16 [ 12313427 ]
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Closed [ 6 ]

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Ivan Dubrov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development