diff --git a/balking/README.md b/balking/README.md index f720c0d02..fb5c83d5b 100644 --- a/balking/README.md +++ b/balking/README.md @@ -18,10 +18,10 @@ incomplete or inappropriate state ## Applicability Use the Balking pattern when -*you want to invoke an action on an object only when it is in a particular state -*objects are generally only in a state that is prone to balking temporarily +* you want to invoke an action on an object only when it is in a particular state +* objects are generally only in a state that is prone to balking temporarily but for an unknown amount of time ## Related patterns * Guarded Suspension Pattern -* Double Checked Locking Pattern \ No newline at end of file +* Double Checked Locking Pattern diff --git a/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java b/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java index 4f3a5930d..69736855c 100644 --- a/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java +++ b/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java @@ -95,7 +95,7 @@ public class FactoryMethodTest { */ private void verifyWeapon(Weapon weapon, WeaponType expectedWeaponType, Class> clazz) { assertTrue("Weapon must be an object of: " + clazz.getName(), clazz.isInstance(weapon)); - assertEquals("Weapon must be of weaponType: " + clazz.getName(), expectedWeaponType, + assertEquals("Weapon must be of weaponType: " + expectedWeaponType, expectedWeaponType, weapon.getWeaponType()); } } diff --git a/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java b/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java index add5617b1..839f27bc7 100644 --- a/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java +++ b/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java @@ -56,7 +56,7 @@ public class PrototypeTest
{ /** * The tested prototype instance */ - private final Prototype testedPrototype; + private final P testedPrototype; /** * The expected {@link Prototype#toString()} value @@ -69,7 +69,7 @@ public class PrototypeTest
{
* @param testedPrototype The tested prototype instance
* @param expectedToString The expected {@link Prototype#toString()} value
*/
- public PrototypeTest(final Prototype testedPrototype, final String expectedToString) {
+ public PrototypeTest(final P testedPrototype, final String expectedToString) {
this.expectedToString = expectedToString;
this.testedPrototype = testedPrototype;
}
diff --git a/throttling/src/main/java/com/iluwatar/throttling/B2BService.java b/throttling/src/main/java/com/iluwatar/throttling/B2BService.java
index c9acd4b73..51ed492eb 100644
--- a/throttling/src/main/java/com/iluwatar/throttling/B2BService.java
+++ b/throttling/src/main/java/com/iluwatar/throttling/B2BService.java
@@ -46,7 +46,7 @@ class B2BService {
*/
public int dummyCustomerApi(Tenant tenant) {
String tenantName = tenant.getName();
- int count = CallsCount.getCount(tenantName);
+ long count = CallsCount.getCount(tenantName);
LOGGER.debug("Counter for {} : {} ", tenant.getName(), count);
if (count >= tenant.getAllowedCallsPerSecond()) {
LOGGER.error("API access per second limit reached for: {}", tenantName);
diff --git a/throttling/src/main/java/com/iluwatar/throttling/CallsCount.java b/throttling/src/main/java/com/iluwatar/throttling/CallsCount.java
index 81195b074..9b274849a 100644
--- a/throttling/src/main/java/com/iluwatar/throttling/CallsCount.java
+++ b/throttling/src/main/java/com/iluwatar/throttling/CallsCount.java
@@ -22,9 +22,13 @@
*/
package com.iluwatar.throttling;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
/**
* A class to keep track of the counter of different Tenants
@@ -32,16 +36,16 @@ import java.util.concurrent.ConcurrentHashMap;
*
*/
public final class CallsCount {
- private static Map