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 2023/07/14 16:22:41 UTC

[commons-pool] 01/06: Flip conditional in test

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

commit 9f87273f988b71ce1dfa378a15190b99ead252b0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jul 14 11:37:08 2023 -0400

    Flip conditional in test
    
    Reduce nesting
---
 .../pool2/impl/DisconnectingWaiterFactory.java       | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/test/java/org/apache/commons/pool2/impl/DisconnectingWaiterFactory.java b/src/test/java/org/apache/commons/pool2/impl/DisconnectingWaiterFactory.java
index 94a38993..1385130b 100644
--- a/src/test/java/org/apache/commons/pool2/impl/DisconnectingWaiterFactory.java
+++ b/src/test/java/org/apache/commons/pool2/impl/DisconnectingWaiterFactory.java
@@ -141,9 +141,8 @@ public class DisconnectingWaiterFactory<K> extends WaiterFactory<K> {
     private boolean validate(final PooledObject<Waiter> obj) {
         if (connected.get()) {
             return super.validateObject(obj);
-        } else {
-            return disconnectedValidationAction.test(obj);
         }
+        return disconnectedValidationAction.test(obj);
     }
 
     @Override
@@ -157,18 +156,18 @@ public class DisconnectingWaiterFactory<K> extends WaiterFactory<K> {
     }
 
     private void activate(final PooledObject<Waiter> obj) {
-        if (!connected.get()) {
-            disconnectedLifcycleAction.accept(obj);
-        } else {
+        if (connected.get()) {
             super.activateObject(obj);
+        } else {
+            disconnectedLifcycleAction.accept(obj);
         }
     }
 
     private void passivate(final PooledObject<Waiter> obj) {
-        if (!connected.get()) {
-            disconnectedLifcycleAction.accept(obj);
-        } else {
+        if (connected.get()) {
             super.passivateObject(obj);
+        } else {
+            disconnectedLifcycleAction.accept(obj);
         }
     }
 
@@ -203,11 +202,10 @@ public class DisconnectingWaiterFactory<K> extends WaiterFactory<K> {
     }
 
     private PooledObject<Waiter> make() {
-        if (!connected.get()) {
-            return disconnectedCreateAction.get();
-        } else {
+        if (connected.get()) {
             return super.makeObject();
         }
+        return disconnectedCreateAction.get();
     }
 
     /**