You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/12/07 22:48:07 UTC

[commons-pool] branch master updated: Fix Checktyle issues.

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 516c86b  Fix Checktyle issues.
516c86b is described below

commit 516c86bd6b1aba9f6823553d86ed98cef9164e0b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 7 17:48:02 2019 -0500

    Fix Checktyle issues.
---
 .../commons/pool2/impl/BaseGenericObjectPool.java  | 61 ++++++++++++++--------
 .../apache/commons/pool2/impl/CallStackUtils.java  |  6 +--
 2 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
index 0857929..17d2bd2 100644
--- a/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
@@ -217,27 +217,32 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
         this.blockWhenExhausted = blockWhenExhausted;
     }
 
-    protected void setConfig(final BaseObjectPoolConfig<T> conf) {
-        setLifo(conf.getLifo());
-        setMaxWaitMillis(conf.getMaxWaitMillis());
-        setBlockWhenExhausted(conf.getBlockWhenExhausted());
-        setTestOnCreate(conf.getTestOnCreate());
-        setTestOnBorrow(conf.getTestOnBorrow());
-        setTestOnReturn(conf.getTestOnReturn());
-        setTestWhileIdle(conf.getTestWhileIdle());
-        setNumTestsPerEvictionRun(conf.getNumTestsPerEvictionRun());
-        setMinEvictableIdleTimeMillis(conf.getMinEvictableIdleTimeMillis());
-        setTimeBetweenEvictionRunsMillis(conf.getTimeBetweenEvictionRunsMillis());
-        setSoftMinEvictableIdleTimeMillis(conf.getSoftMinEvictableIdleTimeMillis());
-        final EvictionPolicy<T> policy = conf.getEvictionPolicy();
+    /**
+     * Initializes the receiver with the given configuration.
+     * 
+     * @param config Initialization source.
+     */
+    protected void setConfig(final BaseObjectPoolConfig<T> config) {
+        setLifo(config.getLifo());
+        setMaxWaitMillis(config.getMaxWaitMillis());
+        setBlockWhenExhausted(config.getBlockWhenExhausted());
+        setTestOnCreate(config.getTestOnCreate());
+        setTestOnBorrow(config.getTestOnBorrow());
+        setTestOnReturn(config.getTestOnReturn());
+        setTestWhileIdle(config.getTestWhileIdle());
+        setNumTestsPerEvictionRun(config.getNumTestsPerEvictionRun());
+        setMinEvictableIdleTimeMillis(config.getMinEvictableIdleTimeMillis());
+        setTimeBetweenEvictionRunsMillis(config.getTimeBetweenEvictionRunsMillis());
+        setSoftMinEvictableIdleTimeMillis(config.getSoftMinEvictableIdleTimeMillis());
+        final EvictionPolicy<T> policy = config.getEvictionPolicy();
         if (policy == null) {
             // Use the class name (pre-2.6.0 compatible)
-            setEvictionPolicyClassName(conf.getEvictionPolicyClassName());
+            setEvictionPolicyClassName(config.getEvictionPolicyClassName());
         } else {
             // Otherwise, use the class (2.6.0 feature)
             setEvictionPolicy(policy);
         }
-        setEvictorShutdownTimeoutMillis(conf.getEvictorShutdownTimeoutMillis());
+        setEvictorShutdownTimeoutMillis(config.getEvictorShutdownTimeoutMillis());
     }
 
     /**
@@ -653,16 +658,22 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
                 setEvictionPolicy(evictionPolicyClassName, epClassLoader);
             }
         } catch (final ClassCastException e) {
-            throw new IllegalArgumentException("Class " + evictionPolicyClassName + " from class loaders ["
-                    + classLoader + ", " + epClassLoader + "] do not implement " + EVICTION_POLICY_TYPE_NAME);
-        } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
-                | InvocationTargetException | NoSuchMethodException e) {
-            final String exMessage = "Unable to create " + EVICTION_POLICY_TYPE_NAME + " instance of type "
-                    + evictionPolicyClassName;
+            throw new IllegalArgumentException("Class " + evictionPolicyClassName + " from class loaders [" +
+                    classLoader + ", " + epClassLoader + "] do not implement " + EVICTION_POLICY_TYPE_NAME);
+        } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException |
+                InvocationTargetException | NoSuchMethodException e) {
+            final String exMessage = "Unable to create " + EVICTION_POLICY_TYPE_NAME + " instance of type " +
+                    evictionPolicyClassName;
             throw new IllegalArgumentException(exMessage, e);
         }
     }
 
+    /**
+     * Sets the eviction policy.
+     * 
+     * @param className Eviction policy class name.
+     * @param classLoader Load the class from this class loader.
+     */
     @SuppressWarnings("unchecked")
     private void setEvictionPolicy(final String className, final ClassLoader classLoader)
             throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
@@ -1156,11 +1167,19 @@ public abstract class BaseGenericObjectPool<T> extends BaseObject {
         }
 
 
+        /**
+         * Sets the scheduled future.
+         * 
+         * @param scheduledFuture the scheduled future.
+         */
         void setScheduledFuture(final ScheduledFuture<?> scheduledFuture) {
             this.scheduledFuture = scheduledFuture;
         }
 
 
+        /**
+         * Cancels the scheduled future.
+         */
         void cancel() {
             scheduledFuture.cancel(false);
         }
diff --git a/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java b/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java
index c1bff0a..6b132a9 100644
--- a/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java
+++ b/src/main/java/org/apache/commons/pool2/impl/CallStackUtils.java
@@ -72,9 +72,9 @@ public final class CallStackUtils {
     public static CallStack newCallStack(final String messageFormat,
                                          final boolean useTimestamp,
                                          final boolean requireFullStackTrace) {
-        return canCreateSecurityManager() && !requireFullStackTrace
-            ? new SecurityManagerCallStack(messageFormat, useTimestamp)
-            : new ThrowableCallStack(messageFormat, useTimestamp);
+        return canCreateSecurityManager() && !requireFullStackTrace ?
+            new SecurityManagerCallStack(messageFormat, useTimestamp) :
+            new ThrowableCallStack(messageFormat, useTimestamp);
     }
 
     /**