diff --git a/pom.xml b/pom.xml
index 1f4efb6d..411daa65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,6 +98,10 @@
org.jenkins-ci.plugins
script-security
+
+ io.jenkins.plugins
+ caffeine-api
+
org.jboss.marshalling
diff --git a/src/main/java/org/jenkinsci/plugins/workflow/support/storage/SimpleXStreamFlowNodeStorage.java b/src/main/java/org/jenkinsci/plugins/workflow/support/storage/SimpleXStreamFlowNodeStorage.java
index 60038225..fc9412dc 100644
--- a/src/main/java/org/jenkinsci/plugins/workflow/support/storage/SimpleXStreamFlowNodeStorage.java
+++ b/src/main/java/org/jenkinsci/plugins/workflow/support/storage/SimpleXStreamFlowNodeStorage.java
@@ -24,15 +24,16 @@
package org.jenkinsci.plugins.workflow.support.storage;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.LoadingCache;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.core.JVM;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+import java.nio.file.NoSuchFileException;
+import java.util.concurrent.CompletionException;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.actions.FlowNodeAction;
@@ -48,7 +49,6 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -57,8 +57,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.logging.Level;
import java.util.logging.Logger;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -71,11 +69,10 @@
public class SimpleXStreamFlowNodeStorage extends FlowNodeStorage {
private final File dir;
private final FlowExecution exec;
- private final LoadingCache nodeCache = CacheBuilder.newBuilder().softValues().build(new CacheLoader() {
- @Override public FlowNode load(String key) throws Exception {
- return SimpleXStreamFlowNodeStorage.this.load(key).node;
- }
- });
+
+ private final LoadingCache nodeCache = Caffeine.newBuilder()
+ .softValues()
+ .build(key -> SimpleXStreamFlowNodeStorage.this.load(key).node);
private static final Logger LOGGER = Logger.getLogger(SimpleXStreamFlowNodeStorage.class.getName());
@@ -99,7 +96,7 @@ public FlowNode getNode(String id) throws IOException {
}
}
return nodeCache.get(id);
- } catch (ExecutionException x) {
+ } catch (CompletionException x) {
Throwable cause = x.getCause();
if (cause instanceof NoSuchFileException) {
LOGGER.finer("Tried to load FlowNode where file does not exist, for id "+id);
@@ -254,7 +251,7 @@ private void storeActions() { // We've already loaded the actions, may as well
XSTREAM.registerConverter(new Converter() {
private final RobustReflectionConverter ref = new RobustReflectionConverter(XSTREAM.getMapper(), JVM.newReflectionProvider());
// IdentityHashMap could leak memory. WeakHashMap compares by equals, which will fail with NPE in FlowNode.hashCode.
- private final Map ids = CacheBuilder.newBuilder().weakKeys().build().asMap();
+ private final Map ids = Caffeine.newBuilder().weakKeys().build().asMap();
@Override public boolean canConvert(Class type) {
return FlowNode.class.isAssignableFrom(type);
}