Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-17856

[GSS](7.2.z) Flash Scope is not cleared when JSF1095 is occurred

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.2.6.CR1, 7.2.6.GA
    • 7.2.5.CR1
    • JSF
    • None
    • +
    • Hide

      If the response is already committed, do not use Flash Scope as the following code:

      try {
          // The response is committed by following code.
          // Therefore, mojarra can not set csfcfc Cookie to identify FlashScope.
          externalContext.responseFlushBuffer();
          facesContext.responseComplete();
      } catch (Exception e) {
          e.printStackTrace();
      }
      
      if (!FacesContext.getCurrentInstance().getExternalContext().isResponseCommitted()) {
          Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
          flash.put("business", businessMap);
      }
      

      Flash Scope is a feature for holding scope during the POST-REDIRECT-GET design pattern. If the response is already committed in the action method and it does not respond REDIRECT, using Flash Scope is meaningless.

      Show
      If the response is already committed, do not use Flash Scope as the following code: try { // The response is committed by following code. // Therefore, mojarra can not set csfcfc Cookie to identify FlashScope. externalContext.responseFlushBuffer(); facesContext.responseComplete(); } catch (Exception e) { e.printStackTrace(); } if (!FacesContext.getCurrentInstance().getExternalContext().isResponseCommitted()) { Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash(); flash.put( "business" , businessMap); } Flash Scope is a feature for holding scope during the POST-REDIRECT-GET design pattern. If the response is already committed in the action method and it does not respond REDIRECT, using Flash Scope is meaningless.
    • Hide

      1. Deploy leak2.war attached in this Jira.
      2. Access http://localhost:8080/leak2/
      3. Click "to Download" button
      4. Click repeatedly "Download". Click several times results in java.lang.OutOfMemory.

      Show
      1. Deploy leak2.war attached in this Jira. 2. Access http://localhost:8080/leak2/ 3. Click "to Download" button 4. Click repeatedly "Download". Click several times results in java.lang.OutOfMemory.

      If committing the response for file download processing and using Flash Scope in the action method are combined as the following code, the Flash Scope will not be cleared in subsequent requests.

      try {
          // The response is committed by following code.
          // Therefore, mojarra can not set csfcfc Cookie to identify FlashScope.
          externalContext.responseFlushBuffer();
          facesContext.responseComplete();
      } catch (Exception e) {
          e.printStackTrace();
      }
      
      Flash flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
      flash.put("business", businessMap);
      

      In other words, if the below log shows in server.log, the Flash Scope will not be cleared in subsequent requests.

      2019-10-28 10:38:09,180 WARNING [javax.enterprise.resource.webcontainer.jsf.flash] (default task-1) JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash.  Any values stored to the flash will not be available on the next request.
      

            spyrkob Bartosz Spyrko-Smietanko
            rhn-support-nagetsum Norito Agetsuma
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: