This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
The following commit(s) were added to refs/heads/master by this push:
new a110a92a Add builders instead of new constructors in
org.apache.commons.pool3.proxy
a110a92a is described below
commit a110a92a02e67a485cfe26c62a7be6958a728fc2
Author: Gary Gregory <[email protected]>
AuthorDate: Wed May 7 17:43:20 2025 -0400
Add builders instead of new constructors in
org.apache.commons.pool3.proxy
- Add org.apache.commons.pool3.proxy.CglibProxySource.Builder
- Add org.apache.commons.pool3.proxy.JdkProxySource.Builder
- Add org.apache.commons.pool3.proxy.AbstractProxySource
- Add final
---
src/changes/changes.xml | 3 +
.../commons/pool3/proxy/AbstractProxySource.java | 97 ++++++++++++++++++++++
.../commons/pool3/proxy/BaseProxyHandler.java | 4 +-
.../commons/pool3/proxy/CglibProxyHandler.java | 19 ++---
.../commons/pool3/proxy/CglibProxySource.java | 81 +++++++++++++-----
.../commons/pool3/proxy/JdkProxyHandler.java | 19 ++---
.../apache/commons/pool3/proxy/JdkProxySource.java | 90 ++++++++++++++++----
.../proxy/AbstractTestProxiedKeyedObjectPool.java | 4 +-
.../pool3/proxy/AbstractTestProxiedObjectPool.java | 6 +-
.../TestProxiedKeyedObjectPoolWithCglibProxy.java | 2 +-
.../TestProxiedKeyedObjectPoolWithJdkProxy.java | 2 +-
.../proxy/TestProxiedObjectPoolWithCglibProxy.java | 13 ++-
.../proxy/TestProxiedObjectPoolWithJdkProxy.java | 15 ++--
13 files changed, 277 insertions(+), 78 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c46290f7..5b758248 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,9 @@ The <action> type attribute can be add,update,fix,remove.
<!-- ADD -->
<action type="add" dev="psteitz" issue="POOL-407">Add
ReslientPooledObjectFactory to provide resilience against factory
outages.</action>
<action type="add" dev="ggregory" issue="POOL-415" due-to="Réda Housni
Alaoui, Gary Gregory, Phil Steitz">Add an option to JdkProxySource allowing to
unwrap UndeclaredThrowableException #261.</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add
org.apache.commons.pool3.proxy.CglibProxySource.Builder.</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add
org.apache.commons.pool3.proxy.JdkProxySource.Builder.</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add
org.apache.commons.pool3.proxy.AbstractProxySource.</action>
<!-- FIX -->
<action type="fix" dev="ggregory" due-to="Gary Gregory">Remove -nouses
directive from maven-bundle-plugin. OSGi package imports now state 'uses'
definitions for package imports, this doesn't affect JPMS (from
org.apache.commons:commons-parent:80).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Operation on the
"idleHighWaterMark" shared variable in "ErodingFactor" class is not atomic
[org.apache.commons.pool3.PoolUtils$ErodingFactor] At PoolUtils.java:[line 101]
AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE.</action>
diff --git
a/src/main/java/org/apache/commons/pool3/proxy/AbstractProxySource.java
b/src/main/java/org/apache/commons/pool3/proxy/AbstractProxySource.java
new file mode 100644
index 00000000..6bdf1094
--- /dev/null
+++ b/src/main/java/org/apache/commons/pool3/proxy/AbstractProxySource.java
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+package org.apache.commons.pool3.proxy;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.function.Supplier;
+
+/**
+ * Abstracts a proxy source implementation.
+ *
+ * @param <T> type of the pooled object to be proxied.
+ * @since 3.0.0
+ */
+public abstract class AbstractProxySource<T> implements ProxySource<T> {
+
+ /**
+ * Abstract a builder implementations.
+ *
+ * @param <T> type of the pooled object to be proxied.
+ * @param <P> the AbstractProxySource subclass
+ * @param <B> the builder subclass.
+ */
+ public abstract static class AbstractBuilder<T, P, B extends
AbstractBuilder<T, P, B>> implements Supplier<P> {
+
+ /**
+ * Whether the proxy throws {@link
InvocationTargetException#getTargetException()} instead of {@link
InvocationTargetException}.
+ */
+ protected boolean unwrapInvocationTargetException;
+
+ /**
+ * Constructs a new instance for a subclass.
+ */
+ public AbstractBuilder() {
+ // empty
+ }
+
+ /**
+ * Returns {@code this} instance typed as a subclass.
+ *
+ * @return {@code this} instance typed as a subclass.
+ */
+ @SuppressWarnings("unchecked")
+ B asThis() {
+ return (B) this;
+ }
+
+ /**
+ * Sets whether the proxy throws {@link
InvocationTargetException#getTargetException()} instead of {@link
InvocationTargetException}.
+ *
+ * @param unwrapInvocationTargetException whether the proxy throws
{@link InvocationTargetException#getTargetException()} instead of
+ * {@link
InvocationTargetException}.
+ * @return {@code this} instance.
+ */
+ public B setUnwrapInvocationTargetException(final boolean
unwrapInvocationTargetException) {
+ this.unwrapInvocationTargetException =
unwrapInvocationTargetException;
+ return asThis();
+ }
+ }
+
+ /**
+ * Whether the proxy throws {@link
InvocationTargetException#getTargetException()} instead of {@link
InvocationTargetException}.
+ */
+ private final boolean unwrapInvocationTargetException;
+
+ /**
+ * Constructs a new instance.
+ *
+ * @param builder Information used to build the new instance.
+ */
+ protected AbstractProxySource(final AbstractBuilder builder) {
+ this.unwrapInvocationTargetException =
builder.unwrapInvocationTargetException;
+ }
+
+ /**
+ * Tests whether the proxy throws {@link
InvocationTargetException#getTargetException()} instead of {@link
InvocationTargetException}.
+ *
+ * @return whether the proxy throws {@link
InvocationTargetException#getTargetException()} instead of {@link
InvocationTargetException}.
+ */
+ protected boolean isUnwrapInvocationTargetException() {
+ return unwrapInvocationTargetException;
+ }
+}
diff --git a/src/main/java/org/apache/commons/pool3/proxy/BaseProxyHandler.java
b/src/main/java/org/apache/commons/pool3/proxy/BaseProxyHandler.java
index 64ae4283..6bc51d87 100644
--- a/src/main/java/org/apache/commons/pool3/proxy/BaseProxyHandler.java
+++ b/src/main/java/org/apache/commons/pool3/proxy/BaseProxyHandler.java
@@ -44,7 +44,7 @@ class BaseProxyHandler<T> {
* @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()}
* instead of {@link
InvocationTargetException}
*/
- BaseProxyHandler(final T pooledObject, final UsageTracking<T>
usageTracking, boolean unwrapInvocationTargetException) {
+ BaseProxyHandler(final T pooledObject, final UsageTracking<T>
usageTracking, final boolean unwrapInvocationTargetException) {
this.pooledObject = pooledObject;
this.usageTracking = usageTracking;
this.unwrapInvocationTargetException = unwrapInvocationTargetException;
@@ -79,7 +79,7 @@ class BaseProxyHandler<T> {
}
try {
return method.invoke(object, args);
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
if (unwrapInvocationTargetException) {
throw e.getTargetException();
}
diff --git
a/src/main/java/org/apache/commons/pool3/proxy/CglibProxyHandler.java
b/src/main/java/org/apache/commons/pool3/proxy/CglibProxyHandler.java
index b269aed4..c944d6aa 100644
--- a/src/main/java/org/apache/commons/pool3/proxy/CglibProxyHandler.java
+++ b/src/main/java/org/apache/commons/pool3/proxy/CglibProxyHandler.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.pool3.proxy;
import java.lang.reflect.InvocationTargetException;
@@ -29,29 +30,27 @@ import net.sf.cglib.proxy.MethodProxy;
* <p>
* CGLib implementation of the proxy handler.
* </p>
+ *
* @param <T> type of the wrapped pooled object
* @since 2.0
*/
-final class CglibProxyHandler<T> extends BaseProxyHandler<T>
- implements MethodInterceptor {
+final class CglibProxyHandler<T> extends BaseProxyHandler<T> implements
MethodInterceptor {
/**
* Constructs a CGLib proxy instance.
*
* @param pooledObject The object to wrap
- * @param usageTracking The instance, if any (usually
the object pool) to
- * be provided with usage tracking
information for this
- * wrapped object
- * @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()}
- * instead of {@link
InvocationTargetException}
+ * @param usageTracking The instance, if any (usually
the object pool) to be provided with usage tracking information for this wrapped
+ * object
+ * @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()} instead of
+ * {@link InvocationTargetException}
*/
- CglibProxyHandler(final T pooledObject, final UsageTracking<T>
usageTracking, boolean unwrapInvocationTargetException) {
+ CglibProxyHandler(final T pooledObject, final UsageTracking<T>
usageTracking, final boolean unwrapInvocationTargetException) {
super(pooledObject, usageTracking, unwrapInvocationTargetException);
}
@Override
- public Object intercept(final Object object, final Method method, final
Object[] args,
- final MethodProxy methodProxy) throws Throwable {
+ public Object intercept(final Object object, final Method method, final
Object[] args, final MethodProxy methodProxy) throws Throwable {
return doInvoke(method, args);
}
}
diff --git a/src/main/java/org/apache/commons/pool3/proxy/CglibProxySource.java
b/src/main/java/org/apache/commons/pool3/proxy/CglibProxySource.java
index 5c1d9979..cab39eb8 100644
--- a/src/main/java/org/apache/commons/pool3/proxy/CglibProxySource.java
+++ b/src/main/java/org/apache/commons/pool3/proxy/CglibProxySource.java
@@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.commons.pool3.proxy;
-import java.lang.reflect.InvocationTargetException;
+package org.apache.commons.pool3.proxy;
import org.apache.commons.pool3.UsageTracking;
@@ -28,33 +27,74 @@ import net.sf.cglib.proxy.Factory;
* <p>
* Provides proxy objects using CGLib.
* </p>
- * @param <T> type of the pooled object to be proxied
+ *
+ * @param <T> type of the pooled object to be proxied.
* @since 2.0
*/
-public class CglibProxySource<T> implements ProxySource<T> {
+public class CglibProxySource<T> extends AbstractProxySource<T> {
- private final Class<? extends T> superclass;
- private final boolean unwrapInvocationTargetException;
+ /**
+ * Builds instances of {@link CglibProxySource}.
+ *
+ * @param <T> type of the pooled object to be proxied.
+ * @since 3.0.0
+ */
+ public static class Builder<T> extends AbstractBuilder<T,
CglibProxySource<T>, Builder<T>> {
+
+ private Class<? extends T> superclass;
+
+ /**
+ * Constructs a new instance.
+ */
+ public Builder() {
+ // empty
+ }
+
+ @Override
+ public CglibProxySource<T> get() {
+ return new CglibProxySource<>(this);
+ }
+
+ /**
+ * Sets the superclass.
+ *
+ * @param superclass the superclass.
+ * @return {@code this} instance.
+ */
+ public Builder<T> setSuperclass(final Class<? extends T> superclass) {
+ this.superclass = superclass;
+ return asThis();
+ }
+ }
/**
- * Constructs a new proxy source for the given class.
+ * Constructs a new builder of {@link CglibProxySource}.
*
- * @param superclass The class to proxy
- * @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()}
- * instead of {@link
InvocationTargetException}
+ * @param <T> type of the pooled object to be proxied.
+ * @return a new builder of {@link CglibProxySource}.
+ * @since 3.0.0
*/
- public CglibProxySource(final Class<? extends T> superclass, boolean
unwrapInvocationTargetException) {
- this.superclass = superclass;
- this.unwrapInvocationTargetException = unwrapInvocationTargetException;
+ public static <T> Builder<T> builder() {
+ return new Builder<>();
+ }
+
+ private final Class<? extends T> superclass;
+
+ private CglibProxySource(final Builder<T> builder) {
+ super(builder);
+ this.superclass = builder.superclass;
}
/**
* Constructs a new proxy source for the given class.
- *
+ * <p>
+ * For additional features, use a {@link #builder()}.
+ * </p>
* @param superclass The class to proxy
*/
public CglibProxySource(final Class<? extends T> superclass) {
- this(superclass, false);
+ super(builder());
+ this.superclass = superclass;
}
@SuppressWarnings("unchecked") // Case to T on return
@@ -62,24 +102,21 @@ public class CglibProxySource<T> implements ProxySource<T>
{
public T createProxy(final T pooledObject, final UsageTracking<T>
usageTracking) {
final Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(superclass);
-
- final CglibProxyHandler<T> proxyInterceptor =
- new CglibProxyHandler<>(pooledObject, usageTracking,
unwrapInvocationTargetException);
+ final CglibProxyHandler<T> proxyInterceptor = new
CglibProxyHandler<>(pooledObject, usageTracking,
isUnwrapInvocationTargetException());
enhancer.setCallback(proxyInterceptor);
-
return (T) enhancer.create();
}
@Override
public T resolveProxy(final T proxy) {
@SuppressWarnings("unchecked")
- final
- CglibProxyHandler<T> cglibProxyHandler =
- (CglibProxyHandler<T>) ((Factory) proxy).getCallback(0);
+ final CglibProxyHandler<T> cglibProxyHandler = (CglibProxyHandler<T>)
((Factory) proxy).getCallback(0);
return cglibProxyHandler.disableProxy();
}
/**
+ * Converts this instance to a string suitable for debugging.
+ *
* @since 2.4.3
*/
@Override
diff --git a/src/main/java/org/apache/commons/pool3/proxy/JdkProxyHandler.java
b/src/main/java/org/apache/commons/pool3/proxy/JdkProxyHandler.java
index 786d5687..4cd63e0d 100644
--- a/src/main/java/org/apache/commons/pool3/proxy/JdkProxyHandler.java
+++ b/src/main/java/org/apache/commons/pool3/proxy/JdkProxyHandler.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.pool3.proxy;
import java.lang.reflect.InvocationHandler;
@@ -28,27 +29,23 @@ import org.apache.commons.pool3.UsageTracking;
* @param <T> type of the wrapped pooled object
* @since 2.0
*/
-final class JdkProxyHandler<T> extends BaseProxyHandler<T>
- implements InvocationHandler {
+final class JdkProxyHandler<T> extends BaseProxyHandler<T> implements
InvocationHandler {
/**
* Constructs a Java reflection proxy instance.
*
* @param pooledObject The object to wrap
- * @param usageTracking The instance, if any (usually
the object pool) to
- * be provided with usage tracking
information for this
- * wrapped object
- * @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()}
- * instead of {@link
InvocationTargetException}
+ * @param usageTracking The instance, if any (usually
the object pool) to be provided with usage tracking information for this wrapped
+ * object
+ * @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()} instead of
+ * {@link InvocationTargetException}
*/
- JdkProxyHandler(final T pooledObject, final UsageTracking<T>
usageTracking, boolean unwrapInvocationTargetException) {
+ JdkProxyHandler(final T pooledObject, final UsageTracking<T>
usageTracking, final boolean unwrapInvocationTargetException) {
super(pooledObject, usageTracking, unwrapInvocationTargetException);
}
@Override
- public Object invoke(final Object proxy, final Method method, final
Object[] args)
- throws Throwable {
+ public Object invoke(final Object proxy, final Method method, final
Object[] args) throws Throwable {
return doInvoke(method, args);
}
}
-
diff --git a/src/main/java/org/apache/commons/pool3/proxy/JdkProxySource.java
b/src/main/java/org/apache/commons/pool3/proxy/JdkProxySource.java
index d621e52e..3ba58cca 100644
--- a/src/main/java/org/apache/commons/pool3/proxy/JdkProxySource.java
+++ b/src/main/java/org/apache/commons/pool3/proxy/JdkProxySource.java
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.pool3.proxy;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.util.Arrays;
@@ -28,42 +28,96 @@ import org.apache.commons.pool3.UsageTracking;
* @param <T> type of the pooled object to be proxied
* @since 2.0
*/
-public class JdkProxySource<T> implements ProxySource<T> {
+public class JdkProxySource<T> extends AbstractProxySource<T> {
- private final ClassLoader classLoader;
- private final Class<?>[] interfaces;
- private final boolean unwrapInvocationTargetException;
+ /**
+ * Builds instances of {@link JdkProxySource}.
+ *
+ * @param <T> type of the pooled object to be proxied.
+ * @since 3.0.0
+ */
+ public static class Builder<T> extends AbstractBuilder<T,
JdkProxySource<T>, Builder<T>> {
+
+ private ClassLoader classLoader;
+ private Class<?>[] interfaces;
+
+ /**
+ * Constructs a new instance.
+ */
+ public Builder() {
+ // empty
+ }
+
+ @Override
+ public JdkProxySource<T> get() {
+ return new JdkProxySource<>(this);
+ }
+
+ /**
+ * Sets the class loader to define the proxy class.
+ *
+ * @param classLoader the class loader to define the proxy class.
+ * @return {@code this} instance.
+ */
+ public Builder<T> setClassLoader(final ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ return asThis();
+ }
+
+ /**
+ * Sets the list of interfaces for the proxy class.
+ *
+ * @param interfaces the list of interfaces for the proxy class.
+ * @return {@code this} instance.
+ */
+ public Builder<T> setInterfaces(final Class<?>... interfaces) {
+ this.interfaces = interfaces != null ? interfaces.clone() : null;
+ return asThis();
+ }
+ }
/**
- * Constructs a new proxy source for the given interfaces.
+ * Constructs a new builder of {@link CglibProxySource}.
*
- * @param classLoader The class loader with which to create the proxy
- * @param interfaces The interfaces to proxy
- * @param unwrapInvocationTargetException True to make the proxy throw
{@link InvocationTargetException#getTargetException()}
- * instead of {@link
InvocationTargetException}
+ * @param <T> type of the pooled object to be proxied.
+ * @return a new builder of {@link CglibProxySource}.
+ * @since 3.0.0
*/
- public JdkProxySource(final ClassLoader classLoader, final Class<?>[]
interfaces, boolean unwrapInvocationTargetException) {
- this.classLoader = classLoader;
- // Defensive copy
- this.interfaces = Arrays.copyOf(interfaces, interfaces.length);
- this.unwrapInvocationTargetException = unwrapInvocationTargetException;
+ public static <T> Builder<T> builder() {
+ return new Builder<>();
+ }
+
+ /** The class loader to define the proxy class. */
+ private final ClassLoader classLoader;
+
+ /** The list of interfaces for the proxy class to implement. */
+ private final Class<?>[] interfaces;
+
+ private JdkProxySource(final Builder<T> builder) {
+ super(builder);
+ this.classLoader = builder.classLoader;
+ this.interfaces = builder.interfaces;
}
/**
* Constructs a new proxy source for the given interfaces.
+ * <p>
+ * For additional features, use a {@link #builder()}.
+ * </p>
*
* @param classLoader The class loader with which to create the proxy
* @param interfaces The interfaces to proxy
*/
public JdkProxySource(final ClassLoader classLoader, final Class<?>[]
interfaces) {
- this(classLoader, interfaces, false);
+ super(builder());
+ this.classLoader = classLoader;
+ this.interfaces = interfaces.clone();
}
@SuppressWarnings("unchecked") // Cast to T on return.
@Override
public T createProxy(final T pooledObject, final UsageTracking<T>
usageTracking) {
- return (T) Proxy.newProxyInstance(classLoader, interfaces,
- new JdkProxyHandler<>(pooledObject, usageTracking,
unwrapInvocationTargetException));
+ return (T) Proxy.newProxyInstance(classLoader, interfaces, new
JdkProxyHandler<>(pooledObject, usageTracking,
isUnwrapInvocationTargetException()));
}
@SuppressWarnings("unchecked")
diff --git
a/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedKeyedObjectPool.java
b/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedKeyedObjectPool.java
index 09aefb58..78b68ce7 100644
---
a/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedKeyedObjectPool.java
+++
b/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedKeyedObjectPool.java
@@ -81,7 +81,7 @@ public abstract class AbstractTestProxiedKeyedObjectPool {
private StringWriter log;
- protected abstract ProxySource<TestObject> getproxySource();
+ protected abstract ProxySource<TestObject> getProxySource();
@BeforeEach
public void setUp() {
@@ -103,7 +103,7 @@ public abstract class AbstractTestProxiedKeyedObjectPool {
@SuppressWarnings("resource")
final KeyedObjectPool<String, TestObject, RuntimeException> innerPool
= new GenericKeyedObjectPool<>(factory, config, abandonedConfig);
- pool = new ProxiedKeyedObjectPool<>(innerPool, getproxySource());
+ pool = new ProxiedKeyedObjectPool<>(innerPool, getProxySource());
}
@Test
diff --git
a/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedObjectPool.java
b/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedObjectPool.java
index f584e53f..b8008410 100644
---
a/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedObjectPool.java
+++
b/src/test/java/org/apache/commons/pool3/proxy/AbstractTestProxiedObjectPool.java
@@ -42,6 +42,7 @@ public abstract class AbstractTestProxiedObjectPool {
String getData();
void setData(String data);
}
+
private static final class TestObjectFactory extends
BasePooledObjectFactory<TestObject, RuntimeException> {
@@ -86,13 +87,14 @@ public abstract class AbstractTestProxiedObjectPool {
this.data = data;
}
}
+
private static final String DATA1 = "data1";
private static final Duration ABANDONED_TIMEOUT_SECS =
Duration.ofSeconds(3);
private StringWriter log;
- protected abstract ProxySource<TestObject> getproxySource(boolean
unwrapInvocationTargetException);
+ protected abstract ProxySource<TestObject> getProxySource(boolean
unwrapInvocationTargetException);
private ProxiedObjectPool<TestObject, RuntimeException>
createProxiedObjectPool() {
return createProxiedObjectPool(false, null);
@@ -115,7 +117,7 @@ public abstract class AbstractTestProxiedObjectPool {
final ObjectPool<TestObject, RuntimeException> innerPool = new
GenericObjectPool<>(factory, config, abandonedConfig);
- return new ProxiedObjectPool<>(innerPool,
getproxySource(unwrapInvocationTargetException));
+ return new ProxiedObjectPool<>(innerPool,
getProxySource(unwrapInvocationTargetException));
}
@BeforeEach
diff --git
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithCglibProxy.java
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithCglibProxy.java
index f916ce8e..bf5fa4f3 100644
---
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithCglibProxy.java
+++
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithCglibProxy.java
@@ -20,7 +20,7 @@ public class TestProxiedKeyedObjectPoolWithCglibProxy extends
AbstractTestProxiedKeyedObjectPool {
@Override
- protected ProxySource<TestObject> getproxySource() {
+ protected ProxySource<TestObject> getProxySource() {
return new CglibProxySource<>(TestObject.class);
}
}
diff --git
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithJdkProxy.java
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithJdkProxy.java
index 21faf831..a05a7385 100644
---
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithJdkProxy.java
+++
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedKeyedObjectPoolWithJdkProxy.java
@@ -20,7 +20,7 @@ public class TestProxiedKeyedObjectPoolWithJdkProxy
extends AbstractTestProxiedKeyedObjectPool {
@Override
- protected ProxySource<TestObject> getproxySource() {
+ protected ProxySource<TestObject> getProxySource() {
return new JdkProxySource<>(this.getClass().getClassLoader(),
new Class<?>[] { TestObject.class });
}
diff --git
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithCglibProxy.java
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithCglibProxy.java
index 289c7a2e..7b0a8360 100644
---
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithCglibProxy.java
+++
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithCglibProxy.java
@@ -14,16 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.pool3.proxy;
import java.lang.reflect.InvocationTargetException;
-public class TestProxiedObjectPoolWithCglibProxy extends
- AbstractTestProxiedObjectPool {
+public class TestProxiedObjectPoolWithCglibProxy extends
AbstractTestProxiedObjectPool {
@Override
- protected ProxySource<TestObject> getproxySource(boolean
unwrapInvocationTargetException) {
- return new CglibProxySource<>(TestObject.class,
unwrapInvocationTargetException);
+ protected ProxySource<TestObject> getProxySource(boolean
unwrapInvocationTargetException) {
+ // @formatter:off
+ return CglibProxySource.<TestObject>builder()
+ .setSuperclass(TestObject.class)
+
.setUnwrapInvocationTargetException(unwrapInvocationTargetException)
+ .get();
+ // @formatter:on
}
@Override
diff --git
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithJdkProxy.java
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithJdkProxy.java
index 73304be6..01894a37 100644
---
a/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithJdkProxy.java
+++
b/src/test/java/org/apache/commons/pool3/proxy/TestProxiedObjectPoolWithJdkProxy.java
@@ -14,17 +14,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.pool3.proxy;
import java.lang.reflect.UndeclaredThrowableException;
-public class TestProxiedObjectPoolWithJdkProxy
- extends AbstractTestProxiedObjectPool {
+public class TestProxiedObjectPoolWithJdkProxy extends
AbstractTestProxiedObjectPool {
@Override
- protected ProxySource<TestObject> getproxySource(boolean
unwrapInvocationTargetException) {
- return new JdkProxySource<>(this.getClass().getClassLoader(),
- new Class<?>[] { TestObject.class },
unwrapInvocationTargetException);
+ protected ProxySource<TestObject> getProxySource(boolean
unwrapInvocationTargetException) {
+ // @formatter:off
+ return JdkProxySource.<TestObject>builder()
+ .setClassLoader(getClass().getClassLoader())
+ .setInterfaces(TestObject.class)
+
.setUnwrapInvocationTargetException(unwrapInvocationTargetException)
+ .get();
+ // @formatter:on
}
@Override