@Override
  protected void initBridgeRequestScope(
      PortletRequest portletRequest, PortletResponse portletResponse, PortletPhase portletPhase) {

    super.initBridgeRequestScope(portletRequest, portletResponse, portletPhase);

    // If the portlet container does not support the POST-REDIRECT-GET design pattern, then the
    // ACTION_PHASE and
    // RENDER_PHASE are both part of a single HTTP POST request. In such cases, the excluded request
    // attributes must
    // be pro-actively removed here in the RENDER_PHASE (providing that the bridge request scope was
    // created in the
    // ACTION_PHASE). Note that this must take place prior to the FacesContext getting constructed.
    // This is because
    // the FacesContextFactory delegation chain might consult a request attribute that is supposed
    // to be excluded.
    // This is indeed the case with Apache Trinidad {@link
    // org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl.CacheRenderKit}
    // constructor, which
    // consults a request attribute named "org.apache.myfaces.trinidad.util.RequestStateMap" that
    // must first be
    // excluded.
    PortalContext portalContext = portletRequest.getPortalContext();
    String postRedirectGetSupport =
        portalContext.getProperty(BridgePortalContext.POST_REDIRECT_GET_SUPPORT);

    if ((postRedirectGetSupport == null)
        && (bridgeRequestScope.getBeganInPhase() == Bridge.PortletPhase.ACTION_PHASE)) {
      bridgeRequestScope.removeExcludedAttributes(renderRequest);
    }
  }
  @Override
  protected void cleanup(PortletRequest portletRequest) {

    // If required, cause the BridgeRequestScope to go out-of-scope.
    if (!bridgeRequestScopePreserved) {
      bridgeRequestScopeCache.remove(bridgeRequestScope.getId());
    }

    super.cleanup(portletRequest);
  }
  @Override
  protected void cleanup() {

    // If required, cause the BridgeRequestScope to go out-of-scope.
    if ((bridgeContext != null) && !bridgeContext.isBridgeRequestScopePreserved()) {
      bridgeRequestScopeCache.remove(bridgeRequestScope.getId());
    }

    super.cleanup();
  }