You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:36 UTC

[myfaces-trinidad] 04/04: TRINIDAD-2052 Native memory issue Defltaer/inflater from StateManagerImpl

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1.2.12.5.1-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit e90ab6858e1d3f5fc4c4013e552e6ffbbb0a3a6a
Author: Gabrielle Crawford <gc...@apache.org>
AuthorDate: Wed Oct 5 17:53:04 2011 +0000

    TRINIDAD-2052 Native memory issue Defltaer/inflater from StateManagerImpl
---
 .../application/StateManagerImpl.java              | 59 ++--------------------
 1 file changed, 5 insertions(+), 54 deletions(-)

diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
index dc072c2..e061b00 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
@@ -55,7 +55,6 @@ import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.context.Window;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ExternalContextUtils;
-import org.apache.myfaces.trinidad.util.TransientHolder;
 import org.apache.myfaces.trinidadinternal.context.RequestContextImpl;
 import org.apache.myfaces.trinidadinternal.context.TrinidadPhaseListener;
 import org.apache.myfaces.trinidadinternal.util.LRUCache;
@@ -1385,27 +1384,11 @@ public class StateManagerImpl extends StateManagerWrapper
 
     private Object _unzipBytes(FacesContext context, byte[] zippedBytes)
     {
-      Inflater decompressor = null;
-      ExternalContext externalContext = context.getExternalContext();
-      Map<String,Object> sessionMap  = externalContext.getSessionMap();
+      Inflater decompressor = new Inflater();
 
       try
       {
-        //Get inflater from session cope
-        TransientHolder<Inflater> th =
-                              (TransientHolder<Inflater>)sessionMap.remove("PAGE_STATE_INFLATER");
-
-        if (th != null)
-        {
-          decompressor = th.getValue();
-        }
-
-        if(decompressor == null)
-        {
-          decompressor = new Inflater();
-        }
-
-		    decompressor.setInput(zippedBytes);
+	decompressor.setInput(zippedBytes);
         ByteArrayOutputStream bos = new ByteArrayOutputStream(zippedBytes.length);
         byte[] buf = new byte[zippedBytes.length*5];
 
@@ -1438,39 +1421,16 @@ public class StateManagerImpl extends StateManagerWrapper
       }
       finally
       {
-        //Reset and put back
-        if(decompressor != null)
-        {
-          decompressor.reset();
-          decompressor.setInput(_EMPTY);
-          TransientHolder<Inflater> th = TransientHolder.newTransientHolder(decompressor);
-          sessionMap.put("PAGE_STATE_INFLATER", th);
-        }
+        decompressor.end();
       }
     }
 
     private void _zipToBytes(FacesContext context, Object viewState)
     {
-      Deflater compresser = null;
-      ExternalContext externalContext = context.getExternalContext();
-      Map<String,Object> sessionMap  = externalContext.getSessionMap();
+      Deflater compresser = new Deflater(Deflater.BEST_SPEED);
 
       try
       {
-        //Get deflater from session cope
-        TransientHolder<Deflater> th =
-                              (TransientHolder<Deflater>)sessionMap.remove("PAGE_STATE_DEFLATER");
-
-        if (th != null)
-        {
-          compresser = th.getValue();
-        }
-
-        if(compresser == null)
-        {
-          compresser = new Deflater(Deflater.BEST_SPEED);
-        }
-
         //Serialize state
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -1500,14 +1460,7 @@ public class StateManagerImpl extends StateManagerWrapper
       }
       finally
       {
-        //Reset and put back
-        if(compresser != null)
-        {
-          compresser.reset();
-          compresser.setInput(_EMPTY);
-          TransientHolder<Deflater> th = TransientHolder.newTransientHolder(compresser);
-          sessionMap.put("PAGE_STATE_DEFLATER", th);
-        }
+        compresser.end();
       }
     }
   }
@@ -1572,7 +1525,5 @@ public class StateManagerImpl extends StateManagerWrapper
 
   private static final long serialVersionUID = 1L;
 
-  private static final byte[] _EMPTY = new byte[0];
-
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(StateManagerImpl.class);
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.