@Override
  public int getBufferSize() {
    if (_lifecycle.equals(PortletRequest.RENDER_PHASE)
        || _lifecycle.equals(PortletRequest.RESOURCE_PHASE)) {

      MimeResponse mimeResponse = _getMimeResponse();

      return mimeResponse.getBufferSize();
    } else {
      return 0;
    }
  }
  /**
   * @see {@link ExternalContext#getResponseBufferSize()}
   * @since JSF 2.0
   */
  @Override
  public int getResponseBufferSize() {

    if (portletResponse instanceof MimeResponse) {
      MimeResponse mimeResponse = (MimeResponse) portletResponse;
      int responseBufferSize = mimeResponse.getBufferSize();

      if (manageIncongruities) {
        incongruityContext.setResponseBufferSize(responseBufferSize);
      }

      return responseBufferSize;
    } else {

      if (manageIncongruities) {
        return incongruityContext.getResponseBufferSize();
      } else {
        throw new IllegalStateException();
      }
    }
  }