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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git


The following commit(s) were added to refs/heads/master by this push:
     new 8f0738d  Use isEmpty().
8f0738d is described below

commit 8f0738d7aa55e7c5116f25fa044166875c451c67
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Jan 17 10:26:30 2021 -0500

    Use isEmpty().
    
    Add IndexedDisk.isEmpty().
---
 .../commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java  | 15 +++++++++++++--
 .../jcs3/auxiliary/disk/indexed/IndexedDiskCache.java     |  4 ++--
 .../auxiliary/lateral/socket/tcp/LateralTCPListener.java  |  2 +-
 src/changes/changes.xml                                   |  5 ++++-
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
index 38b50d2..862b276 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
@@ -219,9 +219,9 @@ public class IndexedDisk implements AutoCloseable
 
     /**
      * Returns the raf length.
-     * <p>
+     * 
      * @return the length of the file.
-     * @throws IOException
+     * @throws IOException If an I/O error occurs.
      */
     protected long length()
         throws IOException
@@ -276,4 +276,15 @@ public class IndexedDisk implements AutoCloseable
     {
         return filepath;
     }
+
+    /**
+     * Tests if the length is 0.
+     * @return true if the if the length is 0.
+     * @throws IOException If an I/O error occurs.
+     * @since 3.1
+     */
+    protected boolean isEmpty() throws IOException 
+    {
+        return length() == 0;
+    }
 }
diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
index 7bcf15a..4cec8d0 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
@@ -232,7 +232,7 @@ public class IndexedDiskCache<K, V> extends 
AbstractDiskCache<K, V>
                     logCacheName);
             initializeEmptyStore();
         }
-        else if (keyFile.length() > 0)
+        else if (!keyFile.isEmpty())
         {
             // If the key file has contents, try to initialize the keys
             // from it. In no keys are loaded reset the data file.
@@ -256,7 +256,7 @@ public class IndexedDiskCache<K, V> extends 
AbstractDiskCache<K, V>
     {
         this.keyHash.clear();
 
-        if (dataFile.length() > 0)
+        if (!dataFile.isEmpty())
         {
             dataFile.reset();
         }
diff --git 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
index c99e7f2..3045253 100644
--- 
a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
+++ 
b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
@@ -158,7 +158,7 @@ public class LateralTCPListener<K, V>
             shutdown = new AtomicBoolean(false);
 
             final ServerSocket serverSocket;
-            if (host != null && host.length() > 0)
+            if (host != null && !host.isEmpty())
             {
                 log.info( "Listening on {0}:{1}", host, port );
                 // Resolve host name
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4fad36a..e5132f4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -20,9 +20,12 @@
        </properties>
        <body>
         <release version="3.1" date="20YY-MM-DD">
-            <action dev="ggregory" type="add">
+            <action dev="ggregory" type="add" due-to="Gary Gregory">
                 Add BlockDiskKeyStore.isEmpty().
             </action>
+            <action dev="ggregory" type="add" due-to="Gary Gregory">
+                Add IndexedDisk.isEmpty().
+            </action>
         </release>
         <release version="3.0" date="2020-08-16">
             <action issue="JCS-205" dev="tv" type="fix">

Reply via email to