Use isEmpty().
Add IndexedDisk.isEmpty().
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 @@
/**
* 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 @@
{
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 @@
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 @@
{
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 @@
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">