You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/01/15 17:19:26 UTC

[tomcat] 02/02: Fix back-port of Pool2 update not to use default methods

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

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 5601e5183ecd32fb53c02e31e58416c263bb172a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jan 15 16:39:00 2021 +0000

    Fix back-port of Pool2 update not to use default methods
---
 java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java         |  4 +---
 .../org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java |  4 +---
 java/org/apache/tomcat/dbcp/pool2/ObjectPool.java              |  4 +---
 java/org/apache/tomcat/dbcp/pool2/PoolUtils.java               | 10 ++++++++++
 java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java     |  4 +---
 .../apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java |  6 ++++++
 6 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java b/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
index 0228dff..72e7b15 100644
--- a/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/KeyedObjectPool.java
@@ -278,9 +278,7 @@ public interface KeyedObjectPool<K, V> extends Closeable {
      * @throws Exception if the instance cannot be invalidated
      * @since 2.9.0
      */
-    default void invalidateObject(final K key, final V obj, final DestroyMode mode) throws Exception {
-        invalidateObject(key, obj);
-    }
+    void invalidateObject(final K key, final V obj, final DestroyMode mode) throws Exception;
 
     /**
      * Return an instance to the pool. By contract, {@code obj}
diff --git a/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java b/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
index 0a24a47..e1a9d74 100644
--- a/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
+++ b/java/org/apache/tomcat/dbcp/pool2/KeyedPooledObjectFactory.java
@@ -129,9 +129,7 @@ public interface KeyedPooledObjectFactory<K, V> {
      * @see DestroyMode
      * @since 2.9.0
      */
-    default void destroyObject(final K key, final PooledObject<V> p, final DestroyMode mode) throws Exception {
-        destroyObject(key, p);
-    }
+    void destroyObject(final K key, final PooledObject<V> p, final DestroyMode mode) throws Exception;
 
     /**
      * Ensures that the instance is safe to be returned by the pool.
diff --git a/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java b/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
index 7e14caa..2647687 100644
--- a/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/ObjectPool.java
@@ -199,9 +199,7 @@ public interface ObjectPool<T> extends Closeable {
      * @throws Exception if the instance cannot be invalidated
      * @since 2.9.0
      */
-    default void invalidateObject(final T obj, final DestroyMode mode) throws Exception {
-        invalidateObject(obj);
-    }
+    void invalidateObject(final T obj, final DestroyMode mode) throws Exception;
 
     /**
      * Returns an instance to the pool. By contract, {@code obj}
diff --git a/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java b/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
index a187c31..b087507 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
@@ -538,6 +538,11 @@ public final class PoolUtils {
             }
         }
 
+        @Override
+        public void destroyObject(PooledObject<T> p, DestroyMode mode) throws Exception {
+            destroyObject(p);
+        }
+
         /**
          * {@inheritDoc}
          */
@@ -657,6 +662,11 @@ public final class PoolUtils {
             }
         }
 
+        @Override
+        public void destroyObject(K key, PooledObject<V> p, DestroyMode mode) throws Exception {
+            destroyObject(key, p);
+        }
+
         /**
          * {@inheritDoc}
          */
diff --git a/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java b/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
index 9c95d0d..daff431 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PooledObjectFactory.java
@@ -122,9 +122,7 @@ public interface PooledObjectFactory<T> {
    * @see DestroyMode
    * @since 2.9.0
    */
-  default void destroyObject(final PooledObject<T> p, final DestroyMode mode) throws Exception {
-      destroyObject(p);
-  }
+  void destroyObject(final PooledObject<T> p, final DestroyMode mode) throws Exception;
 
   /**
    * Ensures that the instance is safe to be returned by the pool.
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java b/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
index f9cce30..6d653e3 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
 import java.util.NoSuchElementException;
 
 import org.apache.tomcat.dbcp.pool2.BaseObjectPool;
+import org.apache.tomcat.dbcp.pool2.DestroyMode;
 import org.apache.tomcat.dbcp.pool2.PoolUtils;
 import org.apache.tomcat.dbcp.pool2.PooledObjectFactory;
 
@@ -245,6 +246,11 @@ public class SoftReferenceObjectPool<T> extends BaseObjectPool<T> {
         notifyAll(); // numActive has changed
     }
 
+    @Override
+    public void invalidateObject(T obj, DestroyMode mode) throws Exception {
+        invalidateObject(obj);
+    }
+
     /**
      * Creates an object, and places it into the pool. addObject() is useful for
      * "pre-loading" a pool with idle objects.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org