Merge pull request #14 from nhojpatrick/junit-4.13.1
JUnit v4.13.1
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..51943ba
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,17 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+The Apache Commons security page is [https://commons.apache.org/security.html](https://commons.apache.org/security.html).
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java
index 7bf290c..0964216 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -121,7 +122,7 @@
.stream()
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(
- entry -> entry.getKey(),
+ Entry::getKey,
entry -> entry.getValue().getVal()));
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp
index b01bef0..313d349 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdmin.jsp
@@ -16,295 +16,293 @@
specific language governing permissions and limitations
under the License.
--%>
+<!DOCTYPE html>
+<%@page import="java.util.List"%>
<%@page import="org.apache.commons.jcs3.JCS"%>
<%@page import="org.apache.commons.jcs3.access.CacheAccess" %>
<%@page import="org.apache.commons.jcs3.admin.CacheElementInfo" %>
<%@page import="org.apache.commons.jcs3.admin.CacheRegionInfo" %>
-<%@page import="java.io.Serializable" %>
-<%@page import="java.util.HashMap" %>
+<%@page import="org.apache.commons.jcs3.engine.behavior.ICacheElement" %>
<jsp:useBean id="jcsBean" scope="request" class="org.apache.commons.jcs3.admin.JCSAdminBean" />
-<html>
+<html lang="en">
<head>
-
-<SCRIPT LANGUAGE="Javascript">
- function decision( message, url )
+ <script>
+ function decision(message, url)
{
- if( confirm(message) )
+ if(confirm(message))
{
location.href = url;
}
}
-</SCRIPT>
+ </script>
+ <style>
+ body {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: small;
+ }
+
+ h1 {
+ font-size: large;
+ color: navy;
+ }
-<title> JCS Admin Servlet </title>
+ h2 {
+ font-size: medium;
+ color: navy;
+ }
+ a {
+ color: navy;
+ font-weight: 700;
+ text-decoration: none;
+ }
+
+ /* Change color on hover */
+ a:hover {
+ background-color: navy;
+ color: white;
+ }
+
+ pre {
+ font-size: medium;
+ }
+
+ table, th, td {
+ border: thin solid #a0a0a0;
+ font-size: small;
+ }
+
+ table {
+ border-collapse: collapse;
+ }
+
+ tr:nth-child(odd) {
+ background: #EEE;
+ }
+
+ th, td {
+ padding: 4pt;
+ }
+
+ th {
+ background-color: navy;
+ color: white;
+ font-weight: 700;
+ text-align: left;
+ }
+ </style>
+ <title>JCS Administration</title>
</head>
-
<body>
-
<%
- String CACHE_NAME_PARAM = "cacheName";
- String ACTION_PARAM = "action";
- String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
- String CLEAR_REGION_ACTION = "clearRegion";
- String REMOVE_ACTION = "remove";
- String DETAIL_ACTION = "detail";
- String REGION_SUMMARY_ACTION = "regionSummary";
- String ITEM_ACTION = "item";
- String KEY_PARAM = "key";
- String SILENT_PARAM = "silent";
+ final String CACHE_NAME_PARAM = "cacheName";
+ final String ACTION_PARAM = "action";
+ final String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
+ final String CLEAR_REGION_ACTION = "clearRegion";
+ final String REMOVE_ACTION = "remove";
+ final String DETAIL_ACTION = "detail";
+ final String REGION_SUMMARY_ACTION = "regionSummary";
+ final String ITEM_ACTION = "item";
+ final String KEY_PARAM = "key";
- String DEFAULT_TEMPLATE_NAME = "DEFAULT";
- String REGION_DETAIL_TEMPLATE_NAME = "DETAIL";
- String ITEM_TEMPLATE_NAME = "ITEM";
- String REGION_SUMMARY_TEMPLATE_NAME = "SUMMARY";
+ final String DEFAULT_TEMPLATE_NAME = "DEFAULT";
+ final String REGION_DETAIL_TEMPLATE_NAME = "DETAIL";
+ final String ITEM_TEMPLATE_NAME = "ITEM";
+ final String REGION_SUMMARY_TEMPLATE_NAME = "SUMMARY";
- String templateName = DEFAULT_TEMPLATE_NAME;
+ String templateName = DEFAULT_TEMPLATE_NAME;
- HashMap<String, Object> context = new HashMap<String, Object>();
+ // Get cacheName for actions from request (might be null)
+ String cacheName = request.getParameter(CACHE_NAME_PARAM);
- // Get cacheName for actions from request (might be null)
- String cacheName = request.getParameter( CACHE_NAME_PARAM );
+ if (cacheName != null)
+ {
+ cacheName = cacheName.trim();
+ }
- if ( cacheName != null )
- {
- cacheName = cacheName.trim();
- }
+ // If an action was provided, handle it
+ String action = request.getParameter(ACTION_PARAM);
- // If an action was provided, handle it
- String action = request.getParameter( ACTION_PARAM );
+ if (action == null)
+ {
+ // do nothing
+ }
+ else if (action.equals(CLEAR_ALL_REGIONS_ACTION))
+ {
+ jcsBean.clearAllRegions();
+ }
+ else if (action.equals(CLEAR_REGION_ACTION) && cacheName != null)
+ {
+ jcsBean.clearRegion(cacheName);
+ }
+ else if (action.equals(REMOVE_ACTION))
+ {
+ for (String key : request.getParameterValues(KEY_PARAM))
+ {
+ jcsBean.removeItem(cacheName, key);
+ }
- if ( action != null )
- {
- if ( action.equals( CLEAR_ALL_REGIONS_ACTION ) )
- {
- jcsBean.clearAllRegions();
- }
- else if ( action.equals( CLEAR_REGION_ACTION ) )
- {
- if ( cacheName == null )
- {
- // Not Allowed
- }
- else
- {
- jcsBean.clearRegion( cacheName );
- }
- }
- else if ( action.equals( REMOVE_ACTION ) )
- {
- String[] keys = request.getParameterValues( KEY_PARAM );
+ templateName = REGION_DETAIL_TEMPLATE_NAME;
+ }
+ else if (action.equals(DETAIL_ACTION))
+ {
+ templateName = REGION_DETAIL_TEMPLATE_NAME;
+ }
+ else if (action.equals(ITEM_ACTION))
+ {
+ templateName = ITEM_TEMPLATE_NAME;
+ }
+ else if (action.equals(REGION_SUMMARY_ACTION))
+ {
+ templateName = REGION_SUMMARY_TEMPLATE_NAME;
+ }
- for ( int i = 0; i < keys.length; i++ )
- {
- jcsBean.removeItem( cacheName, keys[ i ] );
- }
+ ///////////////////////////////////////////////////////////////////////////////////
+ //handle display
- templateName = REGION_DETAIL_TEMPLATE_NAME;
- }
- else if ( action.equals( DETAIL_ACTION ) )
- {
- templateName = REGION_DETAIL_TEMPLATE_NAME;
- }
- else if ( action.equals( ITEM_ACTION ) )
- {
- templateName = ITEM_TEMPLATE_NAME;
- }
- else if ( action.equals( REGION_SUMMARY_ACTION ) )
- {
- templateName = REGION_SUMMARY_TEMPLATE_NAME;
- }
- }
+ if (templateName == ITEM_TEMPLATE_NAME)
+ {
+ String key = request.getParameter(KEY_PARAM);
- if ( request.getParameter( SILENT_PARAM ) != null )
- {
- // If silent parameter was passed, no output should be produced.
- //return null;
- }
- else
- {
- // Populate the context based on the template
- if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
- {
- //context.put( "cacheName", cacheName );
- context.put( "elementInfoRecords", jcsBean.buildElementInfo( cacheName ) );
- }
- else if ( templateName == DEFAULT_TEMPLATE_NAME )
- {
- context.put( "cacheInfoRecords", jcsBean.buildCacheInfo() );
- }
- }
+ if (key != null)
+ {
+ key = key.trim();
+ }
-///////////////////////////////////////////////////////////////////////////////////
- //handle display
-
- if ( templateName == ITEM_TEMPLATE_NAME )
- {
- String key = request.getParameter( KEY_PARAM );
-
- if ( key != null )
- {
- key = key.trim();
- }
-
- CacheAccess<Serializable, Serializable> cache = JCS.getInstance( cacheName );
- org.apache.commons.jcs3.engine.behavior.ICacheElement<?, ?> element = cache.getCacheElement( key );
+ CacheAccess<Object, Object> cache = JCS.getInstance(cacheName);
+ ICacheElement<?, ?> element = cache.getCacheElement(key);
%>
-<h1> Item for key [<%=key%>] in region [<%=cacheName%>] </h1>
-
-<a href="JCSAdmin.jsp?action=detail&cacheName=<%=cacheName%>">Region Detail</a>
-| <a href="JCSAdmin.jsp">All Regions</a>
-
- <pre>
- <%=element%>
- </pre>
+<h1>Item for key [<%=key%>] in region [<%=cacheName%>]</h1>
+<p><a href="?action=detail&cacheName=<%=cacheName%>">Region Detail</a>
+| <a href="?">All Regions</a></p>
+<pre>
+<%=element%>
+</pre>
<%
- }
- else if ( templateName == REGION_SUMMARY_TEMPLATE_NAME )
- {
+ }
+ else if (templateName == REGION_SUMMARY_TEMPLATE_NAME)
+ {
%>
-
-<h1> Summary for region [<%=cacheName%>] </h1>
-
-<a href="JCSAdmin.jsp">All Regions</a>
-
+<h1>Summary for region [<%=cacheName%>]</h1>
+<p><a href="?">All Regions</a></p>
<%
- CacheAccess<?, ?> cache = JCS.getInstance( cacheName );
- String stats = cache.getStats();
+ CacheAccess<?, ?> cache = JCS.getInstance(cacheName);
+ String stats = cache.getStats();
%>
-
- <br>
-<b> Stats for region [<%=cacheName%>] </b>
-
- <pre>
- <%=stats%>
- </pre>
-
+<h2>Statistics for region [<%=cacheName%>]</h2>
+<pre>
+<%=stats%>
+</pre>
<%
- }
- else if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
- {
+ }
+ else if (templateName == REGION_DETAIL_TEMPLATE_NAME)
+ {
%>
-
-<h1> Detail for region [<%=cacheName%>] </h1>
-
-<a href="JCSAdmin.jsp">All Regions</a>
-
-<table border="1" cellpadding="5" >
- <tr>
- <th> Key </th>
- <th> Eternal? </th>
- <th> Create time </th>
- <th> Max Life (s) </th>
- <th> Till Expiration (s) </th>
- </tr>
+<h1>Detail for region [<%=cacheName%>]</h1>
+<p><a href="?">All Regions</a></p>
+<table>
+ <tr>
+ <th>Key</th>
+ <th>Eternal?</th>
+ <th>Create time</th>
+ <th>Max Life (s)</th>
+ <th>Till Expiration (s)</th>
+ </tr>
<%
- CacheElementInfo[] list = (CacheElementInfo[]) context.get( "elementInfoRecords" );
- for (CacheElementInfo element : list)
- {
+ for (CacheElementInfo element : jcsBean.buildElementInfo(cacheName))
+ {
%>
- <tr>
- <td> <%=element.getKey()%> </td>
- <td> <%=element.isEternal()%> </td>
- <td> <%=element.getCreateTime()%> </td>
- <td> <%=element.getMaxLifeSeconds()%> </td>
- <td> <%=element.getExpiresInSeconds()%> </td>
- <td>
- <a href="JCSAdmin.jsp?action=item&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> View </a>
- | <a href="JCSAdmin.jsp?action=remove&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> Remove </a>
- </td>
- </tr>
+ <tr>
+ <td><%=element.getKey()%></td>
+ <td><%=element.isEternal()%></td>
+ <td><%=element.getCreateTime()%></td>
+ <td><%=element.getMaxLifeSeconds()%></td>
+ <td><%=element.getExpiresInSeconds()%></td>
+ <td>
+ <a href="?action=item&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> View </a>
+ | <a href="?action=remove&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> Remove </a>
+ </td>
+ </tr>
+<%
+ }
+
+ CacheAccess<?, ?> cache = JCS.getInstance(cacheName);
+ String stats = cache.getStats();
+%>
+</table>
+<h2>Statistics for region [<%=cacheName%>]</h2>
+<pre>
+<%=stats%>
+</pre>
<%
}
-
- CacheAccess<?, ?> cache = JCS.getInstance( cacheName );
- String stats = cache.getStats();
+ else
+ {
%>
- </table>
-
- <br>
-<b> Stats for region [<%=cacheName%>] </b>
-
- <pre>
- <%=stats%>
- </pre>
-<%
- }
- else
- {
-%>
-
-<h1> Cache Regions </h1>
-
+<h1>Cache Regions</h1>
<p>
These are the regions which are currently defined in the cache. 'Items' and
'Bytes' refer to the elements currently in memory (not spooled). You can clear
-all items for a region by selecting 'Remove all' next to the desired region
-below. You can also <a href="javascript:decision('Clicking OK will clear all the data from all regions!','JCSAdmin.jsp?action=clearAllRegions')">Clear all regions</a>
+all items for a region by selecting 'Clear' next to the desired region
+below. You can also <a href="javascript:decision('Clicking OK will clear all the data from all regions!','?action=clearAllRegions')">Clear all regions</a>
which empties the entire cache.
</p>
-<p>
- <form action="JCSAdmin.jsp">
- <input type="hidden" name="action" value="item">
- Retrieve (key) <input type="text" name="key">
- (region) <select name="cacheName">
+<form action="?"><p>
+ <input type="hidden" name="action" value="item" />
+ Retrieve <input type="text" name="key" autofocus="autofocus" placeholder="(key)" />
+ from region <select name="cacheName">
<%
- CacheRegionInfo[] listSelect = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
- for (CacheRegionInfo record : listSelect)
- {
- %>
+ List<CacheRegionInfo> records = jcsBean.buildCacheInfo();
+
+ for (CacheRegionInfo record : records)
+ {
+%>
<option value="<%=record.getCacheName()%>"><%=record.getCacheName()%></option>
- <%
- }
-%>
- </select>
- <input type="submit">
- </form>
-</p>
-
-<table border="1" cellpadding="5" >
- <tr>
- <th> Cache Name </th>
- <th> Items </th>
- <th> Bytes </th>
- <th> Status </th>
- <th> Memory Hits </th>
- <th> Aux Hits </th>
- <th> Not Found Misses </th>
- <th> Expired Misses </th>
- </tr>
-
<%
- CacheRegionInfo[] list = (CacheRegionInfo[]) context.get( "cacheInfoRecords" );
- for (CacheRegionInfo record : listSelect)
- {
+ }
%>
- <tr>
- <td> <%=record.getCacheName()%> </td>
- <td> <%=record.getCacheSize()%> </td>
- <td> <%=record.getByteCount()%> </td>
- <td> <%=record.getCacheStatus()%> </td>
- <td> <%=record.getHitCountRam()%> </td>
- <td> <%=record.getHitCountAux()%> </td>
- <td> <%=record.getMissCountNotFound()%> </td>
- <td> <%=record.getMissCountExpired()%> </td>
- <td>
- <a href="JCSAdmin.jsp?action=regionSummary&cacheName=<%=record.getCacheName()%>"> Summary </a>
- | <a href="JCSAdmin.jsp?action=detail&cacheName=<%=record.getCacheName()%>"> Detail </a>
- | <a href="javascript:decision('Clicking OK will remove all the data from the region [<%=record.getCacheName()%>]!','JCSAdmin.jsp?action=clearRegion&cacheName=<%=record.getCacheName()%>')"> Clear </a>
- </td>
- </tr>
+ </select>
+ <input type="submit" value="Retrieve" />
+</p></form>
+<table>
+ <tr>
+ <th>Cache Name</th>
+ <th>Items</th>
+ <th>Bytes</th>
+ <th>Status</th>
+ <th>Memory Hits</th>
+ <th>Aux Hits</th>
+ <th>Not Found Misses</th>
+ <th>Expired Misses</th>
+ <th>Actions</th>
+ </tr>
+<%
+ for (CacheRegionInfo record : records)
+ {
+%>
+ <tr>
+ <td><%=record.getCacheName()%></td>
+ <td><%=record.getCacheSize()%></td>
+ <td><%=record.getByteCount()%></td>
+ <td><%=record.getCacheStatus()%></td>
+ <td><%=record.getHitCountRam()%></td>
+ <td><%=record.getHitCountAux()%></td>
+ <td><%=record.getMissCountNotFound()%></td>
+ <td><%=record.getMissCountExpired()%></td>
+ <td>
+ <a href="?action=regionSummary&cacheName=<%=record.getCacheName()%>">Summary</a>
+ | <a href="?action=detail&cacheName=<%=record.getCacheName()%>">Detail</a>
+ | <a href="javascript:decision('Clicking OK will remove all the data from the region [<%=record.getCacheName()%>]!','?action=clearRegion&cacheName=<%=record.getCacheName()%>')">Clear</a>
+ </td>
+ </tr>
+<%
+ }
+%>
+</table>
<%
}
%>
- </table>
-<%
- }
-%>
-
-
</body>
-
</html>
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
index d1468a7..e53dd69 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
@@ -96,7 +96,7 @@
// Convert all keys to string, store in a sorted map
TreeMap<String, ?> keys = new TreeMap<>(cache.getMemoryCache().getKeySet()
.stream()
- .collect(Collectors.toMap(k -> k.toString(), k -> k)));
+ .collect(Collectors.toMap(Object::toString, k -> k)));
LinkedList<CacheElementInfo> records = new LinkedList<>();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java
index 8a1ed09..bfb231b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java
@@ -71,7 +71,7 @@
})
.filter(element -> element != null)
.collect(Collectors.toMap(
- element -> element.getKey(),
+ ICacheElement::getKey,
element -> element));
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
index 54e6919..2a421d3 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
@@ -26,6 +26,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
@@ -269,8 +270,8 @@
key -> processGet( key ))).entrySet().stream()
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(
- entry -> entry.getKey(),
- entry -> entry.getValue()));
+ Entry::getKey,
+ Entry::getValue));
return elements;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
index 99ab390..1a70699 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
@@ -150,7 +150,7 @@
*/
protected TableState getTableState(String tableName)
{
- return tableStates.computeIfAbsent(tableName, key -> new TableState(key));
+ return tableStates.computeIfAbsent(tableName, TableState::new);
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java
index 352f6ba..ffd2cde 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java
@@ -187,7 +187,7 @@
tableState.setState( TableState.FREE );
log.info( "Optimization of table [{0}] took {1} ms.",
- () -> this.getTableName(), () -> timer.getElapsedTime() );
+ this::getTableName, () -> timer.getElapsedTime() );
}
return success;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java
index b85616b..e2fff84 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java
@@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
@@ -173,8 +174,8 @@
key -> get(key))).entrySet().stream()
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(
- entry -> entry.getKey(),
- entry -> entry.getValue()));
+ Entry::getKey,
+ Entry::getValue));
return elements;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java
index 18e4c22..7649718 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java
@@ -26,6 +26,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -232,8 +233,8 @@
key -> get(key))).entrySet().stream()
.filter(entry -> entry.getValue() != null)
.collect(Collectors.toMap(
- entry -> entry.getKey(),
- entry -> entry.getValue()));
+ Entry::getKey,
+ Entry::getValue));
return elements;
}
@@ -301,7 +302,7 @@
@Override
public void removeAll()
{
- Arrays.stream(noWaits).forEach(nw -> nw.removeAll());
+ Arrays.stream(noWaits).forEach(LateralCacheNoWait::removeAll);
}
/** Adds a dispose request to the lateral cache. */
@@ -316,7 +317,7 @@
listener = null;
}
- Arrays.stream(noWaits).forEach(nw -> nw.dispose());
+ Arrays.stream(noWaits).forEach(LateralCacheNoWait::dispose);
}
finally
{
@@ -376,7 +377,7 @@
}
List<CacheStatus> statii = Arrays.stream(noWaits)
- .map(nw -> nw.getStatus())
+ .map(LateralCacheNoWait::getStatus)
.collect(Collectors.toList());
// It's alive if ANY of its nowaits is alive
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
index 84119e2..ccd9dd5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
@@ -229,9 +229,7 @@
public <K, V> RemoteCacheNoWait<K, V> getCache( IRemoteCacheAttributes cattr )
{
RemoteCacheNoWait<K, V> remoteCacheNoWait =
- (RemoteCacheNoWait<K, V>) caches.computeIfAbsent(cattr.getCacheName(), key -> {
- return newRemoteCacheNoWait(cattr);
- });
+ (RemoteCacheNoWait<K, V>) caches.computeIfAbsent(cattr.getCacheName(), key -> newRemoteCacheNoWait(cattr));
// might want to do some listener sanity checking here.
return remoteCacheNoWait;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java
index 427992d..e05ec03 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java
@@ -222,7 +222,7 @@
if (factoryInUse != null && !factoryInUse.getClass().getName().startsWith("org.apache.commons.jcs3"))
{
log.info("Could not create new custom socket factory. {0} Factory in use = {1}",
- () -> e.getMessage(), () -> RMISocketFactory.getSocketFactory());
+ () -> e.getMessage(), RMISocketFactory::getSocketFactory);
}
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CacheWatchRepairable.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CacheWatchRepairable.java
index 342479b..bc41de7 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CacheWatchRepairable.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CacheWatchRepairable.java
@@ -91,9 +91,7 @@
{
// Record the added cache listener locally, regardless of whether the
// remote add-listener operation succeeds or fails.
- Set<ICacheListener<?, ?>> listenerSet = cacheMap.computeIfAbsent(cacheName, key -> {
- return new CopyOnWriteArraySet<>();
- });
+ Set<ICacheListener<?, ?>> listenerSet = cacheMap.computeIfAbsent(cacheName, key -> new CopyOnWriteArraySet<>());
listenerSet.add( obj );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java
index e1de16c..8dd1e26 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/control/CompositeCache.java
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
@@ -788,8 +789,8 @@
getMatchingFromMemory(pattern).entrySet().stream(),
getMatchingFromAuxiliaryCaches(pattern, localOnly).entrySet().stream())
.collect(Collectors.toMap(
- entry -> entry.getKey(),
- entry -> entry.getValue(),
+ Entry::getKey,
+ Entry::getValue,
// Prefer memory entries
(mem, aux) -> mem));
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractDoubleLinkedListMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractDoubleLinkedListMemoryCache.java
index 55479c5..85a846c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractDoubleLinkedListMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractDoubleLinkedListMemoryCache.java
@@ -62,7 +62,7 @@
{
super.initialize(hub);
list = new DoubleLinkedList<>();
- log.info("initialized MemoryCache for {0}", () -> getCacheName());
+ log.info("initialized MemoryCache for {0}", this::getCacheName);
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java
index dec6227..c9f1d59 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractMemoryCache.java
@@ -131,7 +131,7 @@
})
.filter(element -> element != null)
.collect(Collectors.toMap(
- element -> element.getKey(),
+ ICacheElement::getKey,
element -> element));
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java
index 8d9fa7b..cfccb25 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/lru/LHMLRUMemoryCache.java
@@ -49,7 +49,7 @@
public void initialize( CompositeCache<K, V> hub )
{
super.initialize( hub );
- log.info( "initialized LHMLRUMemoryCache for {0}", () -> getCacheName() );
+ log.info( "initialized LHMLRUMemoryCache for {0}", this::getCacheName );
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/soft/SoftReferenceMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/soft/SoftReferenceMemoryCache.java
index 9776ac2..d89537b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/soft/SoftReferenceMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/memory/soft/SoftReferenceMemoryCache.java
@@ -76,7 +76,7 @@
super.initialize( hub );
strongReferences = new LinkedBlockingQueue<>();
log.info( "initialized Soft Reference Memory Cache for {0}",
- () -> getCacheName() );
+ this::getCacheName );
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/MessageFormatter.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/MessageFormatter.java
index fbabfa9..1a50f74 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/MessageFormatter.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/MessageFormatter.java
@@ -65,7 +65,7 @@
{
this.messagePattern = messagePattern;
this.parameters = Arrays.stream(paramSuppliers)
- .map(s -> s.get())
+ .map(Supplier::get)
.toArray();
final int length = parameters == null ? 0 : parameters.length;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
index 361b90a..0684d8c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/discovery/UDPDiscoveryReceiver.java
@@ -208,7 +208,7 @@
cnt.incrementAndGet();
- log.debug( "{0} messages received.", () -> getCnt() );
+ log.debug( "{0} messages received.", this::getCnt );
UDPDiscoveryMessage message = null;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java
index 7cfb139..82a1c7f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/struct/AbstractLRUMap.java
@@ -160,7 +160,7 @@
public Collection<V> values()
{
return map.values().stream()
- .map(value -> value.getPayload())
+ .map(LRUElementDescriptor::getPayload)
.collect(Collectors.toList());
}
@@ -536,7 +536,7 @@
public Set<K> keySet()
{
return map.values().stream()
- .map(value -> value.getKey())
+ .map(LRUElementDescriptor::getKey)
.collect(Collectors.toSet());
}
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCache.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCache.java
index 9e18e7c..ed21fe0 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCache.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCache.java
@@ -24,7 +24,6 @@
import java.util.Map;
import java.util.Set;
-import org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCache;
import org.apache.commons.jcs3.engine.CacheStatus;
import org.apache.commons.jcs3.engine.behavior.ICacheElement;
import org.apache.commons.jcs3.engine.stats.behavior.IStats;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheAttributes.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheAttributes.java
index 5eaa7fe..b67041f 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheAttributes.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheAttributes.java
@@ -1,7 +1,5 @@
package org.apache.commons.jcs3.auxiliary;
-import org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCacheAttributes;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheFactory.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheFactory.java
index 98ad210..3498967 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheFactory.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/MockAuxiliaryCacheFactory.java
@@ -19,7 +19,6 @@
* under the License.
*/
-import org.apache.commons.jcs3.auxiliary.AbstractAuxiliaryCacheFactory;
import org.apache.commons.jcs3.engine.behavior.ICompositeCacheManager;
import org.apache.commons.jcs3.engine.behavior.IElementSerializer;
import org.apache.commons.jcs3.engine.logging.behavior.ICacheEventLogger;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheUnitTest.java
index 1ec3488..420ff08 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheUnitTest.java
@@ -27,11 +27,8 @@
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.apache.commons.jcs3.TestLogConfigurationUtil;
import org.apache.commons.jcs3.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache;
import org.apache.commons.jcs3.auxiliary.disk.behavior.IDiskCacheAttributes;
import org.apache.commons.jcs3.auxiliary.disk.indexed.IndexedDiskCacheAttributes;
import org.apache.commons.jcs3.engine.CacheElement;
@@ -40,6 +37,8 @@
import org.apache.commons.jcs3.engine.behavior.ICacheElement;
import org.apache.commons.jcs3.engine.behavior.IElementAttributes;
+import junit.framework.TestCase;
+
/** Tests for the abstract disk cache. It's largely tested by actual instances. */
public class AbstractDiskCacheUnitTest
extends TestCase
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java
index d0fe76a..84bde7a 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java
@@ -25,7 +25,6 @@
import java.nio.charset.StandardCharsets;
import java.util.Map;
-import org.apache.commons.jcs3.auxiliary.disk.block.BlockDiskCacheAttributes;
import org.apache.commons.jcs3.engine.CacheElement;
import org.apache.commons.jcs3.engine.ElementAttributes;
import org.apache.commons.jcs3.engine.behavior.ICacheElement;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java
index d83bf91..5ba05a2 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java
@@ -27,14 +27,13 @@
import org.apache.commons.jcs3.auxiliary.MockCacheEventLogger;
import org.apache.commons.jcs3.auxiliary.disk.DiskTestObject;
-import org.apache.commons.jcs3.utils.timing.SleepUtil;
-import org.apache.commons.jcs3.auxiliary.disk.indexed.IndexedDiskCacheAttributes;
import org.apache.commons.jcs3.engine.CacheElement;
import org.apache.commons.jcs3.engine.ElementAttributes;
import org.apache.commons.jcs3.engine.behavior.ICacheElement;
import org.apache.commons.jcs3.engine.behavior.IElementAttributes;
import org.apache.commons.jcs3.engine.control.group.GroupAttrName;
import org.apache.commons.jcs3.engine.control.group.GroupId;
+import org.apache.commons.jcs3.utils.timing.SleepUtil;
import junit.framework.TestCase;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServerStartupUtil.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
index a2624cb..3f48c18 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/remote/server/RemoteCacheServerStartupUtil.java
@@ -24,7 +24,6 @@
import java.util.Properties;
import org.apache.commons.jcs3.auxiliary.remote.RemoteUtils;
-import org.apache.commons.jcs3.auxiliary.remote.server.RemoteCacheServer;
import org.apache.commons.jcs3.log.Log;
import org.apache.commons.jcs3.log.LogManager;
import org.apache.commons.jcs3.utils.net.HostNameUtil;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/engine/control/MockCompositeCacheManager.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/engine/control/MockCompositeCacheManager.java
index 18a025e..a415660 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/engine/control/MockCompositeCacheManager.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/engine/control/MockCompositeCacheManager.java
@@ -26,7 +26,6 @@
import org.apache.commons.jcs3.engine.ElementAttributes;
import org.apache.commons.jcs3.engine.behavior.ICompositeCacheManager;
import org.apache.commons.jcs3.engine.behavior.IShutdownObserver;
-import org.apache.commons.jcs3.engine.control.CompositeCache;
/** For testing. */
public class MockCompositeCacheManager