Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-8565

Rendering cache does not work on JBOSS AS7

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.4-rc-1
    • Component/s: Old Core
    • Labels:
      None
    • Environment:
      JBoss AS7
    • Difficulty:
      Trivial
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      I suspect behaviour is related to JBOSS AS7 but may not be.

      When you request a xwiki page with parameters, even if the parameters are kepts the same, you have a cache miss. So page is rendered each time. Reason is this code, in DefaultRenderingCache

          private String getRequestParameters(XWikiContext context)
          {
              if (context.getRequest() != null) {
                  Map<String, String> parameters = context.getRequest().getParameterMap();
      
                  if (parameters != null) {
                      if (parameters.containsKey(PARAMETER_REFRESH)) {
                          parameters = new HashMap<String, String>(parameters);
      
                          parameters.remove(PARAMETER_REFRESH);
                      }
      
                      return parameters.toString();
                  }
              }
      
              return "";
          }
      

      It renders something like

      {menu=[Ljava.lang.String;@3e5da853, xpage=[Ljava.lang.String;@76d60121} 

      which is then used in the cache key along with page name and source code.
      This comes from the fact HttpServletRequest.getParameterMap() return String -> String[] association, event if parameters have only one value.

      Solution is to replace method with this code:

          private String getRequestParameters(XWikiContext context)
          {
              if (context.getRequest() != null) {
                  Map<String, Object> parameters = context.getRequest().getParameterMap();            
                  StringBuffer buffer = new StringBuffer(50);
                  buffer.append('{');
                  for (Map.Entry<String,Object> item : parameters.entrySet()){
                  	if (!PARAMETER_REFRESH.equals(item.getKey())){
      	            	buffer.append(item.getKey()).append('=');
      	            	if (item.getValue() instanceof Object[])
      	            		buffer.append(Arrays.deepToString((Object[])item.getValue()));
      	            	else
      	            		buffer.append(item.getValue());
                  	}
                  }
                  buffer.append('}');
                  return buffer.toString();
              }
      
              return "";
          }
      

      And then, no more problems.

        Attachments

          Activity

            People

            • Assignee:
              tmortagne Thomas Mortagne
              Reporter:
              tchize David Delbecq
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Date of First Response: