You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2017/11/25 08:38:48 UTC

[1/2] [lang] LANG-1370 Fix EventCountCircuitBreaker increment batch

Repository: commons-lang
Updated Branches:
  refs/heads/master 6049e77fd -> dd2394323


LANG-1370 Fix EventCountCircuitBreaker increment batch

Fixes #incrementAndCheckState(Integer increment) by passing the increment downstream.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/7d061e33
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/7d061e33
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/7d061e33

Branch: refs/heads/master
Commit: 7d061e33e59e23dc4b03378f35f50a7d70f033b3
Parents: 6049e77
Author: Andre Dieb Martins <an...@gmail.com>
Authored: Wed Nov 22 13:44:23 2017 -0500
Committer: Bruno P. Kinoshita <ki...@apache.org>
Committed: Sat Nov 25 21:32:52 2017 +1300

----------------------------------------------------------------------
 .../lang3/concurrent/EventCountCircuitBreaker.java   |  2 +-
 .../concurrent/EventCountCircuitBreakerTest.java     | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/7d061e33/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java b/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
index b40213e..dd282dc 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
@@ -271,7 +271,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
     @Override
     public boolean incrementAndCheckState(final Integer increment)
             throws CircuitBreakingException {
-        return performStateCheck(1);
+        return performStateCheck(increment);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/7d061e33/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java
index 1c9e794..0053554 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java
@@ -155,6 +155,21 @@ public class EventCountCircuitBreakerTest {
     }
 
     /**
+     * Tests that the circuit breaker opens if all conditions are met when using
+     * {@link EventCountCircuitBreaker#incrementAndCheckState(Integer increment)}.
+     */
+    @Test
+    public void testOpeningWhenThresholdReachedThroughBatch() {
+        final long timeIncrement = NANO_FACTOR / OPENING_THRESHOLD - 1;
+        final EventCountCircuitBreakerTestImpl breaker = new EventCountCircuitBreakerTestImpl(OPENING_THRESHOLD, 1,
+            TimeUnit.SECONDS, CLOSING_THRESHOLD, 1, TimeUnit.SECONDS);
+        long startTime = timeIncrement * (OPENING_THRESHOLD + 1);
+        boolean open = !breaker.at(startTime).incrementAndCheckState(OPENING_THRESHOLD + 1);
+        assertTrue("Not open", open);
+        assertFalse("Closed", breaker.isClosed());
+    }
+
+    /**
      * Tests that an open circuit breaker does not close itself when the number of events
      * received is over the threshold.
      */


[2/2] [lang] LANG-1370: Add changes.xml entry

Posted by ki...@apache.org.
LANG-1370: Add changes.xml entry


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/dd239432
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/dd239432
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/dd239432

Branch: refs/heads/master
Commit: dd2394323b441e7a22d3c85ce751b619918ee161
Parents: 7d061e3
Author: Bruno P. Kinoshita <ki...@apache.org>
Authored: Sat Nov 25 21:38:17 2017 +1300
Committer: Bruno P. Kinoshita <ki...@apache.org>
Committed: Sat Nov 25 21:38:17 2017 +1300

----------------------------------------------------------------------
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/dd239432/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 07461be..612816b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.8" date="2017-MM-DD" description="New features and bug fixes. Requires Java 7, supports Java 8, 9, 10.">
+    <action issue="LANG-1370" type="fix" dev="kinow" due-to="Andre Dieb">Fix EventCountCircuitBreaker increment batch</action>
     <action issue="LANG-1367" type="update" dev="ggregory" due-to="Gary Gregory">ObjectUtils.identityToString(Object) and friends should allocate builders and buffers with a size</action>
   </release>