You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/07/15 12:30:57 UTC

[myfaces] branch master updated: cosmetics

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

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new e6f3838  cosmetics
e6f3838 is described below

commit e6f383837af05fba953c8c608b4a6ad637e24618
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Mon Jul 15 14:30:48 2019 +0200

    cosmetics
---
 .../application/viewstate/ClientSideStateCacheImpl.java       |  5 ++---
 .../application/viewstate/SerializedViewCollection.java       |  4 ++--
 .../application/viewstate/ServerSideStateCacheImpl.java       | 11 +++++++----
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java b/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java
index b237759..46ab8cc 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/ClientSideStateCacheImpl.java
@@ -58,8 +58,7 @@ class ClientSideStateCacheImpl extends StateCache<Object, Object>
     }
 
     @Override
-    public Object saveSerializedView(FacesContext facesContext,
-            Object serializedView)
+    public Object saveSerializedView(FacesContext facesContext, Object serializedView)
     {
         // The state in this case the state is saved on the token sent to
         // the client (isWriteStateAfterRenderViewRequired() is set to true).
@@ -80,7 +79,7 @@ class ClientSideStateCacheImpl extends StateCache<Object, Object>
                 return null;
             }
 
-            long passedTime = (System.currentTimeMillis() - timeStamp.longValue()) / 60000;
+            long passedTime = (System.currentTimeMillis() - timeStamp) / 60000;
             if (passedTime > clientViewStateTimeout)
             {
                 //expire
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java b/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
index ac0ea59..32b8ea4 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/SerializedViewCollection.java
@@ -169,7 +169,7 @@ class SerializedViewCollection implements Serializable
                         {
                             Integer vscount = _viewScopeIdCounts.get(oldViewScopeId);
                             vscount = vscount - 1;
-                            if (vscount != null && vscount < 1)
+                            if (vscount < 1)
                             {
                                 _viewScopeIdCounts.remove(oldViewScopeId);
                                 viewScopeProvider.destroyViewScopeMap(context, oldViewScopeId);
@@ -212,7 +212,7 @@ class SerializedViewCollection implements Serializable
                 {
                     Integer vscount = _viewScopeIdCounts.get(oldViewScopeId);
                     vscount = vscount - 1;
-                    if (vscount != null && vscount < 1)
+                    if (vscount < 1)
                     {
                         _viewScopeIdCounts.remove(oldViewScopeId);
                         viewScopeProvider.destroyViewScopeMap(context, oldViewScopeId);
diff --git a/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java b/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java
index b208c87..cfd595a 100644
--- a/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/viewstate/ServerSideStateCacheImpl.java
@@ -347,9 +347,10 @@ class ServerSideStateCacheImpl extends StateCache<Object, Object>
                     os.write(UNCOMPRESSED_FLAG);
                 }
 
-                ObjectOutputStream out = new ObjectOutputStream(os);
-                out.writeObject(serializedView);
-                out.close();
+                try (ObjectOutputStream out = new ObjectOutputStream(os))
+                {
+                    out.writeObject(serializedView);
+                }
                 
                 baos.close();
 
@@ -394,11 +395,13 @@ class ServerSideStateCacheImpl extends StateCache<Object, Object>
             try
             {
                 ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) state);
+
                 InputStream is = bais;
-                if(is.read() == COMPRESSED_FLAG)
+                if (is.read() == COMPRESSED_FLAG)
                 {
                     is = new GZIPInputStream(is);
                 }
+
                 ObjectInputStream ois = null;
                 try
                 {