Uploaded image for project: '[Read Only] - Hippo Site Toolkit 2'
  1. [Read Only] - Hippo Site Toolkit 2
  2. HSTTWO-3700

Inform developers about hst component rendering waste

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • 4.0.0
    • None
    • None
    • Platform Sprint 132

    Description

      In HST 2.26 we used to log a warning when there was waste from some component that got rendered but never got anything included in the response. Since this is extremely useful information, we will restore this warning. For 'processing only hst components' that do not render content, we will provide an hst property to suppress this logging. Something like

      hst:ignorewastemessage = true

      (ok and then a bit different name)

      protected void processWindowsRender(final HstContainerConfig requestContainerConfig,
                                              final HstComponentWindow[] sortedComponentWindows, final Map<HstComponentWindow, HstRequest> requestMap,
                                              final Map<HstComponentWindow, HstResponse> responseMap) throws ContainerException {
      
              for (int i = sortedComponentWindows.length - 1; i >= 0; i--) {
                  HstComponentWindow window = sortedComponentWindows[i];
                  if (!window.isVisible()) {
                      continue;
                  }
      
                  HstRequest request = requestMap.get(window);
                  if (isAsync(window, request)) {
                      continue;
                  }
                  HstResponse response = responseMap.get(window);
                  getComponentInvoker().invokeRender(requestContainerConfig, request, response);
      
                  if (log.isWarnEnabled()) {
                      if (window.getChildWindowMap() != null) {
                          for (HstComponentWindow childWindow : window.getChildWindowMap().values()) {
                              final HstResponse childResponse = responseMap.get(childWindow);
                              if (!(childResponse instanceof HstResponseImpl)) {
                                  continue;
                              }
                              final HstResponseImpl childResponseImpl = (HstResponseImpl)childResponse;
                              if (!childWindow.getResponseState().isFlushed() && StringUtils.isNotBlank(getRenderer(childWindow, childResponseImpl))) {
                                  if (childResponse.getHeadElements() == null || childResponse.getHeadElements().isEmpty()) {
                                      // there is a window with a renderer but the content is never included in its ancestor component : That
                                      // is a waste. Hence this warning
                                      log.warn("Component '{}' gets rendered but never adds anything to the response. Component id is '{}' " +
                                              " and renderer '{}' is never flushed to a parent component. This is waste.",
                                              new String[]{childWindow.getName(), childWindow.getComponentInfo().getId(), getRenderer(childWindow, childResponseImpl)});
                                  } else {
                                      // there is a window with a renderer but the content is never included in its ancestor component apart from some
                                      // head elements : this is potential waste and unintended behavior has this info
                                      log.info("Component '{}' gets rendered but except for some head element(s) adds nothing to the response. Component id is '{}' " +
                                              " and renderer '{}' is never flushed to a parent component. This component might be waste.",
                                              new String[]{childWindow.getName(), childWindow.getComponentInfo().getId(), getRenderer(childWindow, childResponseImpl)});
                                  }
                              }
                          }
                      }
                  }
      
              }
          }
      
       private String getRenderer(final HstComponentWindow window, final HstResponseImpl hstResponse) {
              String dispatchUrl = hstResponse.getRenderPath();
              if (StringUtils.isNotBlank(dispatchUrl)) {
                  return dispatchUrl;
              }
              dispatchUrl = window.getRenderPath();
              if (StringUtils.isNotBlank(dispatchUrl)) {
                  return dispatchUrl;
              }
              return window.getNamedRenderer();
          }
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            aschrijvers Ard Schrijvers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: