reduce usage of Guava (#5038)

Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
diff --git a/connectors/apache-connector/pom.xml b/connectors/apache-connector/pom.xml
index dd13cbc..12e882b 100644
--- a/connectors/apache-connector/pom.xml
+++ b/connectors/apache-connector/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!--
 
-    Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -55,11 +55,6 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/connectors/apache5-connector/pom.xml b/connectors/apache5-connector/pom.xml
index 669ac11..f790ec1 100644
--- a/connectors/apache5-connector/pom.xml
+++ b/connectors/apache5-connector/pom.xml
@@ -55,11 +55,6 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/connectors/jetty-connector/pom.xml b/connectors/jetty-connector/pom.xml
index 4619c0c..4e33c50 100644
--- a/connectors/jetty-connector/pom.xml
+++ b/connectors/jetty-connector/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!--
 
-    Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -66,11 +66,6 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/connectors/netty-connector/pom.xml b/connectors/netty-connector/pom.xml
index 877d377..7c1e3f3 100644
--- a/connectors/netty-connector/pom.xml
+++ b/connectors/netty-connector/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!--
 
-    Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -49,11 +49,6 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/containers/jdk-http/pom.xml b/containers/jdk-http/pom.xml
index 111748a..5b95935 100644
--- a/containers/jdk-http/pom.xml
+++ b/containers/jdk-http/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -34,9 +34,10 @@
 
     <dependencies>
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
             <scope>test</scope>
+            <version>${commons.io.version}</version>
         </dependency>
     </dependencies>
 
diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java
index 042a383..e814720 100644
--- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java
+++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -30,6 +30,7 @@
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLHandshakeException;
 
+import org.apache.commons.io.IOUtils;
 import org.glassfish.jersey.SslConfigurator;
 import org.glassfish.jersey.internal.util.JdkVersion;
 import org.glassfish.jersey.server.ResourceConfig;
@@ -37,8 +38,6 @@
 import org.junit.After;
 import org.junit.Test;
 
-import com.google.common.io.ByteStreams;
-
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.HttpsConfigurator;
 import com.sun.net.httpserver.HttpsServer;
@@ -188,9 +187,9 @@
 
 
         final SslConfigurator sslConfigClient = SslConfigurator.newInstance()
-                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
+                .trustStoreBytes(IOUtils.toByteArray(trustStore))
                 .trustStorePassword(TRUSTSTORE_CLIENT_PWD)
-                .keyStoreBytes(ByteStreams.toByteArray(keyStore))
+                .keyStoreBytes(IOUtils.toByteArray(keyStore))
                 .keyPassword(KEYSTORE_CLIENT_PWD);
 
         return sslConfigClient.createSSLContext();
@@ -201,9 +200,9 @@
         final InputStream keyStore = JdkHttpsServerTest.class.getResourceAsStream(KEYSTORE_SERVER_FILE);
 
         final SslConfigurator sslConfigServer = SslConfigurator.newInstance()
-                .keyStoreBytes(ByteStreams.toByteArray(keyStore))
+                .keyStoreBytes(IOUtils.toByteArray(keyStore))
                 .keyPassword(KEYSTORE_SERVER_PWD)
-                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
+                .trustStoreBytes(IOUtils.toByteArray(trustStore))
                 .trustStorePassword(TRUSTSTORE_SERVER_PWD);
 
         return sslConfigServer.createSSLContext();
diff --git a/examples/rx-client-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/ListenableFutureAgentResource.java b/examples/rx-client-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/ListenableFutureAgentResource.java
index 5cfbc45..df68d25 100644
--- a/examples/rx-client-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/ListenableFutureAgentResource.java
+++ b/examples/rx-client-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/ListenableFutureAgentResource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -12,6 +12,8 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -31,8 +33,6 @@
 import org.glassfish.jersey.server.ManagedAsync;
 import org.glassfish.jersey.server.Uri;
 
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -80,7 +80,7 @@
             public void onFailure(final Throwable t) {
                 async.resume(t);
             }
-        });
+        }, Executors.newSingleThreadExecutor());
     }
 
     private ListenableFuture<AgentResponse> visited(final AgentResponse response) {
@@ -97,11 +97,11 @@
                                                                        });
 
         // ... and set them to the final response.
-        return Futures.transform(visited, (AsyncFunction<List<Destination>, AgentResponse>) destinations -> {
+        return Futures.transform(visited, destinations -> {
             response.setVisited(destinations);
 
-            return Futures.immediateFuture(response);
-        });
+            return response;
+        }, Executors.newSingleThreadExecutor());
     }
 
     private ListenableFuture<AgentResponse> recommended(final AgentResponse response) {
@@ -120,15 +120,14 @@
 
         // ... transform them to Recommendation instances ...
         final ListenableFuture<List<Recommendation>> recommendations = Futures.transform(
-                destinations,
-                (AsyncFunction<List<Destination>, List<Recommendation>>) destinationList -> {
+                destinations, destinationList -> {
                     // Create new array list to avoid multiple remote calls.
-                    final List<Recommendation> recommendationList = Lists.newArrayList(Lists.transform(
-                            destinationList,
-                            destination -> new Recommendation(destination.getDestination(), null, 0)));
+                    final List<Recommendation> recommendationList = destinationList.stream().map(
+                            destination -> new Recommendation(destination.getDestination(), null, 0))
+                            .collect(Collectors.toList());
 
-                    return Futures.immediateFuture(recommendationList);
-                });
+                    return recommendationList;
+                }, Executors.newSingleThreadExecutor());
 
         // ... add forecasts and calculations ...
         final ListenableFuture<List<List<Recommendation>>> filledRecommendations = Futures
@@ -140,47 +139,51 @@
 
         // ... and transform the list into agent response with filled recommendations.
         return Futures
-                .transform(filledRecommendations, (AsyncFunction<List<List<Recommendation>>, AgentResponse>) input -> {
+                .transform(filledRecommendations, input -> {
                     response.setRecommended(input.get(0));
 
-                    return Futures.immediateFuture(response);
-                });
+                    return response;
+                }, Executors.newSingleThreadExecutor());
     }
 
     private ListenableFuture<List<Recommendation>> forecasts(final ListenableFuture<List<Recommendation>> recommendations) {
         forecast.register(RxListenableFutureInvokerProvider.class);
 
         // Fill the list with weather forecast.
-        return Futures.transform(recommendations, (AsyncFunction<List<Recommendation>, List<Recommendation>>) list ->
+        return Futures.transform(recommendations, list ->
                 // For each recommendation ...
-                Futures.successfulAsList(Lists.transform(list, recommendation -> Futures.transform(
+                (List<Recommendation>) Futures.successfulAsList(list.stream().map(recommendation -> Futures.transform(
                         // ... get the weather forecast ...
                         forecast.resolveTemplate("destination", recommendation.getDestination()).request()
                                 .rx(RxListenableFutureInvoker.class)
                                 .get(Forecast.class),
                         // ... and set it to the recommendation.
-                        (AsyncFunction<Forecast, Recommendation>) forecast -> {
+                        forecast -> {
                             recommendation.setForecast(forecast.getForecast());
-                            return Futures.immediateFuture(recommendation);
-                        }))));
+                            return recommendation;
+                        },
+                        Executors.newSingleThreadExecutor())).collect(Collectors.toList())),
+                Executors.newSingleThreadExecutor());
     }
 
     private ListenableFuture<List<Recommendation>> calculations(final ListenableFuture<List<Recommendation>> recommendations) {
         calculation.register(RxListenableFutureInvokerProvider.class);
 
         // Fill the list with price calculations.
-        return Futures.transform(recommendations, (AsyncFunction<List<Recommendation>, List<Recommendation>>) list ->
+        return Futures.transform(recommendations, list ->
                 // For each recommendation ...
-                Futures.successfulAsList(Lists.transform(list, recommendation -> Futures.transform(
+                (List<Recommendation>) Futures.successfulAsList(list.stream().map(recommendation -> Futures.transform(
                         // ... get the price calculation ...
                         calculation.resolveTemplate("from", "Moon")
                                    .resolveTemplate("to", recommendation.getDestination())
                                    .request().rx(RxListenableFutureInvoker.class).get(Calculation.class),
                         // ... and set it to the recommendation.
-                        (AsyncFunction<Calculation, Recommendation>) calculation -> {
+                        calculation -> {
                             recommendation.setPrice(calculation.getPrice());
-                            return Futures.immediateFuture(recommendation);
-                        })))
+                            return recommendation;
+                        },
+                        Executors.newSingleThreadExecutor())).collect(Collectors.toList())),
+                Executors.newSingleThreadExecutor()
         );
     }
 }
diff --git a/ext/rx/rx-client-guava/pom.xml b/ext/rx/rx-client-guava/pom.xml
index 48035da..bbd3f34 100644
--- a/ext/rx/rx-client-guava/pom.xml
+++ b/ext/rx/rx-client-guava/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!--
 
-    Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -41,6 +41,7 @@
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
+            <version>${guava.version}</version>
         </dependency>
     </dependencies>
 </project>
diff --git a/pom.xml b/pom.xml
index b03e3b2..dacd060 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1528,11 +1528,11 @@
                 <version>${jta.api.version}</version>
             </dependency>
 
-            <dependency>
+            <!--<dependency>
                 <groupId>com.google.guava</groupId>
                 <artifactId>guava</artifactId>
                 <version>${guava.version}</version>
-            </dependency>
+            </dependency>--> <!-- The latest repackaged guava version is 18.0 -->
 
             <dependency>
                 <groupId>org.glassfish.hk2</groupId>
@@ -2108,6 +2108,7 @@
         <bnd.plugin.version>2.3.6</bnd.plugin.version>
         <cdi.api.version>1.1</cdi.api.version>
         <cdi2.api.version>2.0.2</cdi2.api.version>
+        <commons.io.version>2.11.0</commons.io.version>
         <commons-lang3.version>3.3.2</commons-lang3.version>
         <microprofile.config.version>2.0</microprofile.config.version>
         <checkstyle.mvn.plugin.version>3.1.0</checkstyle.mvn.plugin.version>
@@ -2121,7 +2122,7 @@
         <gae.version>1.9.59</gae.version>
         <grizzly.client.version>1.16</grizzly.client.version>
         <grizzly2.version>2.4.4</grizzly2.version>
-        <guava.version>18.0</guava.version>
+        <guava.version>31.1-jre</guava.version>
         <hamcrest.version>1.3</hamcrest.version>
         <helidon.version>1.0.3</helidon.version>
         <xmlunit.version>1.6</xmlunit.version>
diff --git a/test-framework/maven/container-runner-maven-plugin/pom.xml b/test-framework/maven/container-runner-maven-plugin/pom.xml
index 132a5df..5ec2c34 100644
--- a/test-framework/maven/container-runner-maven-plugin/pom.xml
+++ b/test-framework/maven/container-runner-maven-plugin/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -119,12 +119,6 @@
             <version>${project.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>27.0.1-jre</version>
-        </dependency>
-
     </dependencies>
 
     <build>
diff --git a/test-framework/maven/custom-enforcer-rules/pom.xml b/test-framework/maven/custom-enforcer-rules/pom.xml
index 1c3294a..f490ab0 100644
--- a/test-framework/maven/custom-enforcer-rules/pom.xml
+++ b/test-framework/maven/custom-enforcer-rules/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -46,12 +46,7 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.7</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
+            <version>${commons.io.version}</version>
         </dependency>
 
         <dependency>
diff --git a/test-framework/maven/custom-enforcer-rules/src/main/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRule.java b/test-framework/maven/custom-enforcer-rules/src/main/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRule.java
index 8872e15..5906b3e 100644
--- a/test-framework/maven/custom-enforcer-rules/src/main/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRule.java
+++ b/test-framework/maven/custom-enforcer-rules/src/main/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,18 +19,16 @@
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.util.Arrays;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
 import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
 import org.apache.maven.plugins.enforcer.AbstractNonCacheableEnforcerRule;
 
-import com.google.common.io.Files;
-import com.google.common.io.LineProcessor;
-
 /**
  * Maven enforcer rule to enforce that given file does not contain line matching given pattern. When matched, exception is
  * raised.
@@ -67,25 +65,8 @@
         final Pattern patternCompiled = Pattern.compile(pattern);
         try {
 
-            final List<String> lines = Files.readLines(file, Charset.defaultCharset(), new LineProcessor<List<String>>() {
-                private List<String> matchedLines = new LinkedList<>();
-
-                @Override
-                public boolean processLine(final String line) throws IOException {
-                    if (patternCompiled.matcher(line).matches()) {
-                        matchedLines.add(line);
-                        if (maxMatchedLines != 0 && maxMatchedLines <= matchedLines.size()) {
-                            return false;
-                        }
-                    }
-                    return true;
-                }
-
-                @Override
-                public List<String> getResult() {
-                    return matchedLines;
-                }
-            });
+            final List<String> lines = Files.lines(file.toPath(), Charset.defaultCharset())
+                    .filter(line -> patternCompiled.matcher(line).matches()).collect(Collectors.toList());
 
             if (lines.size() > 0) {
                 throw new EnforcerRuleException(
diff --git a/test-framework/memleak-test-common/pom.xml b/test-framework/memleak-test-common/pom.xml
index c08d129..67598bb 100644
--- a/test-framework/memleak-test-common/pom.xml
+++ b/test-framework/memleak-test-common/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -41,10 +41,6 @@
             <artifactId>junit</artifactId>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
     </dependencies>
 
 </project>
diff --git a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakUtils.java b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakUtils.java
index e19b2c9..d519d3f 100644
--- a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakUtils.java
+++ b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,17 +22,15 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
+import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.Arrays;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import javax.management.MBeanServer;
 
-import com.google.common.io.Files;
-import com.google.common.io.LineProcessor;
-
 /**
  * Utility class for memory leak test infrastructure.
  *
@@ -87,22 +85,8 @@
             return;
         }
 
-        final List<String> lines = Files.readLines(logFile, Charset.defaultCharset(), new LineProcessor<List<String>>() {
-            private List<String> matchedLines = new LinkedList<>();
-
-            @Override
-            public boolean processLine(final String line) throws IOException {
-                if (PATTERN.matcher(line).matches()) {
-                    matchedLines.add(line);
-                }
-                return true;
-            }
-
-            @Override
-            public List<String> getResult() {
-                return matchedLines;
-            }
-        });
+        final List<String> lines = Files.lines(logFile.toPath(), Charset.defaultCharset())
+                .filter(line -> PATTERN.matcher(line).matches()).collect(Collectors.toList());
 
         if (lines.size() > 0) {
             throw new IllegalStateException(
diff --git a/tests/e2e-client/pom.xml b/tests/e2e-client/pom.xml
index a9b0a41..8cf45b0 100644
--- a/tests/e2e-client/pom.xml
+++ b/tests/e2e-client/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -174,13 +174,6 @@
         </dependency>
 
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>org.glassfish.jersey.test-framework</groupId>
             <artifactId>jersey-test-framework-util</artifactId>
             <scope>test</scope>
diff --git a/tests/e2e-entity/pom.xml b/tests/e2e-entity/pom.xml
index 09ce274..5d913de 100644
--- a/tests/e2e-entity/pom.xml
+++ b/tests/e2e-entity/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -171,13 +171,6 @@
         </dependency>
 
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>org.glassfish.jersey.test-framework</groupId>
             <artifactId>jersey-test-framework-util</artifactId>
             <scope>test</scope>
diff --git a/tests/e2e-server/pom.xml b/tests/e2e-server/pom.xml
index df25460..a334bd5 100644
--- a/tests/e2e-server/pom.xml
+++ b/tests/e2e-server/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -166,13 +166,6 @@
         </dependency>
 
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>org.glassfish.jersey.test-framework</groupId>
             <artifactId>jersey-test-framework-util</artifactId>
             <scope>test</scope>
diff --git a/tests/e2e/pom.xml b/tests/e2e/pom.xml
index 0c31034..e9136a5 100644
--- a/tests/e2e/pom.xml
+++ b/tests/e2e/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -171,13 +171,6 @@
         </dependency>
 
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>org.glassfish.jersey.test-framework</groupId>
             <artifactId>jersey-test-framework-util</artifactId>
             <scope>test</scope>
diff --git a/tests/integration/jersey-2612/pom.xml b/tests/integration/jersey-2612/pom.xml
index 6f13ea5..f8c557b 100644
--- a/tests/integration/jersey-2612/pom.xml
+++ b/tests/integration/jersey-2612/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -39,11 +39,6 @@
         </dependency>
 
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
-
-        <dependency>
             <groupId>org.glassfish.jersey.test-framework.providers</groupId>
             <artifactId>jersey-test-framework-provider-external</artifactId>
             <scope>test</scope>
diff --git a/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/OptionalParamConverterProvider.java b/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/OptionalParamConverterProvider.java
index 25b6edf..92849cf 100644
--- a/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/OptionalParamConverterProvider.java
+++ b/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/OptionalParamConverterProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,6 +19,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 
 import javax.ws.rs.ext.ParamConverter;
@@ -32,9 +33,6 @@
 import org.glassfish.jersey.internal.util.ReflectionHelper;
 import org.glassfish.jersey.internal.util.collection.ClassTypePair;
 
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-
 @Singleton
 public class OptionalParamConverterProvider implements ParamConverterProvider {
 
@@ -53,7 +51,7 @@
             return new ParamConverter<T>() {
                 @Override
                 public T fromString(final String value) {
-                    return rawType.cast(Optional.fromNullable(value));
+                    return rawType.cast(Optional.ofNullable(value));
                 }
 
                 @Override
@@ -71,8 +69,7 @@
                 return new ParamConverter<T>() {
                     @Override
                     public T fromString(final String value) {
-                        return rawType.cast(Optional.fromNullable(value)
-                                                    .transform((Function<String, Object>) s -> converter.fromString(value)));
+                        return rawType.cast(Optional.ofNullable(value).map(o -> converter.fromString(value)));
                     }
 
                     @Override
diff --git a/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/Resource.java b/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/Resource.java
index ad1be27..bc8cd89 100644
--- a/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/Resource.java
+++ b/tests/integration/jersey-2612/src/main/java/org/glassfish/jersey/tests/integration/jersey2612/Resource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,9 +20,8 @@
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
+import java.util.Optional;
+import java.util.function.Function;
 
 /**
  * Test resource.
@@ -34,19 +33,15 @@
     @GET
     @Produces("text/plain")
     public String hello(@QueryParam("name") final Optional<String> name) {
-        return "Hello " + name.or("World") + "!";
+        return "Hello " + name.orElse("World") + "!";
     }
 
     @Path("square")
     @GET
     @Produces("text/plain")
     public int echo(@QueryParam("value") final Optional<Integer> value) {
-        return value.transform(new Function<Integer, Integer>() {
-            @Override
-            public Integer apply(final Integer integer) {
-                return integer * integer;
-            }
-        }).or(0);
+
+        return value.map(integer -> integer * integer).orElse(0);
     }
 
 }
diff --git a/tests/integration/jersey-4321/pom.xml b/tests/integration/jersey-4321/pom.xml
index 77df827..002d569 100644
--- a/tests/integration/jersey-4321/pom.xml
+++ b/tests/integration/jersey-4321/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
     Copyright (c) 2019 Christian Kaltepoth. All rights reserved.
 
     This program and the accompanying materials are made available under the
@@ -44,11 +44,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.glassfish.jersey.connectors</groupId>
             <artifactId>jersey-apache-connector</artifactId>
             <exclusions>
diff --git a/tests/integration/property-check/pom.xml b/tests/integration/property-check/pom.xml
index 399c27c..9ac0bab 100644
--- a/tests/integration/property-check/pom.xml
+++ b/tests/integration/property-check/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -93,6 +93,7 @@
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <scope>test</scope>
+            <version>${guava.version}</version>
         </dependency>
     </dependencies>
 
diff --git a/tests/mem-leaks/redeployment/redeployment-leaking-test-app/pom.xml b/tests/mem-leaks/redeployment/redeployment-leaking-test-app/pom.xml
index cf9fab5..5ce4a95 100644
--- a/tests/mem-leaks/redeployment/redeployment-leaking-test-app/pom.xml
+++ b/tests/mem-leaks/redeployment/redeployment-leaking-test-app/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -101,11 +101,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
-
     </dependencies>
 
     <profiles>
diff --git a/tests/mem-leaks/redeployment/redeployment-leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/DaemonThreadMemoryLeakingResource.java b/tests/mem-leaks/redeployment/redeployment-leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/DaemonThreadMemoryLeakingResource.java
index 369f581..24dcd3a 100644
--- a/tests/mem-leaks/redeployment/redeployment-leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/DaemonThreadMemoryLeakingResource.java
+++ b/tests/mem-leaks/redeployment/redeployment-leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/DaemonThreadMemoryLeakingResource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,6 +16,8 @@
 
 package org.glassfish.jersey.tests.memleaks.testleak;
 
+import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder;
+
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
@@ -28,7 +30,6 @@
 
 import javax.inject.Singleton;
 
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
 /**
  * Resource that causes {@link OutOfMemoryError} exception upon repetitive call of {@link #invoke(int)} of an application that is
diff --git a/tests/mem-leaks/test-cases/leaking-test-app/pom.xml b/tests/mem-leaks/test-cases/leaking-test-app/pom.xml
index 53da399..dfa8c24 100644
--- a/tests/mem-leaks/test-cases/leaking-test-app/pom.xml
+++ b/tests/mem-leaks/test-cases/leaking-test-app/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -67,11 +67,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
-
     </dependencies>
 
     <profiles>
diff --git a/tests/mem-leaks/test-cases/leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResource.java b/tests/mem-leaks/test-cases/leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResource.java
index f3cccf2..eb61f0b 100644
--- a/tests/mem-leaks/test-cases/leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResource.java
+++ b/tests/mem-leaks/test-cases/leaking-test-app/src/main/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -25,9 +25,6 @@
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
 
 import javax.inject.Singleton;
 
diff --git a/tools/jersey-release-notes-maven-plugin/pom.xml b/tools/jersey-release-notes-maven-plugin/pom.xml
index e7f2e0c..a9c74ec 100644
--- a/tools/jersey-release-notes-maven-plugin/pom.xml
+++ b/tools/jersey-release-notes-maven-plugin/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -74,7 +74,7 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.6</version>
+            <version>2.11.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.maven</groupId>