diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolder.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolder.java index 327261a2ef40..908a8c1a7ba4 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolder.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolder.java @@ -71,7 +71,7 @@ public class ServiceReferenceHolder { private ConfigurationContextService cfgCtxService; private APIManagerConfigurationService amConfigService; - public ThrottleDataHolder throttleDataHolder; + private final ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); private ThrottleProperties throttleProperties; private ConfigurationContext axis2ConfigurationContext; private TracingService tracingService; @@ -100,9 +100,7 @@ public class ServiceReferenceHolder { private Set activeTenants = new ConcurrentSkipListSet<>(); private JedisPool redisPool; - public void setThrottleDataHolder(ThrottleDataHolder throttleDataHolder) { - this.throttleDataHolder = throttleDataHolder; - } + public ThrottleDataHolder getThrottleDataHolder() { return throttleDataHolder; } diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/listeners/ServerStartupListener.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/listeners/ServerStartupListener.java index 230217fc136a..b9ceccbf065f 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/listeners/ServerStartupListener.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/listeners/ServerStartupListener.java @@ -44,14 +44,11 @@ public void completedServerStartup() { // This prevents errors in an All in one setup caused by the ThrottleDataPublisher trying to connect to the // event receiver, before the event receiver has been started on completion of server startup. ServiceReferenceHolder.getInstance().setThrottleDataPublisher(new ThrottleDataPublisher()); - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); - APIThrottleDataServiceImpl throttleDataServiceImpl = - new APIThrottleDataServiceImpl(throttleDataHolder); + APIThrottleDataServiceImpl throttleDataServiceImpl = new APIThrottleDataServiceImpl(); CacheInvalidationService cacheInvalidationService = new CacheInvalidationServiceImpl(); // Register APIThrottleDataService so that ThrottleData maps are available to other components. ServiceReferenceHolder.getInstance().setCacheInvalidationService(cacheInvalidationService); ServiceReferenceHolder.getInstance().setAPIThrottleDataService(throttleDataServiceImpl); - ServiceReferenceHolder.getInstance().setThrottleDataHolder(throttleDataHolder); ServiceReferenceHolder.getInstance().setRevokedTokenService(new RevokedTokenDataImpl()); SubscriptionsDataService subscriptionsDataService = new SubscriptionsDataServiceImpl(); ServiceReferenceHolder.getInstance().setSubscriptionsDataService(subscriptionsDataService); diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/service/APIThrottleDataServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/service/APIThrottleDataServiceImpl.java index e5c79e1ad2a5..623bf1189142 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/service/APIThrottleDataServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/service/APIThrottleDataServiceImpl.java @@ -32,12 +32,7 @@ */ public class APIThrottleDataServiceImpl implements APIThrottleDataService { - private ThrottleDataHolder throttleDataHolder; - - public APIThrottleDataServiceImpl(ThrottleDataHolder throttleDataHolder) { - - this.throttleDataHolder = throttleDataHolder; - } + private ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); @Override public void addThrottledApiConditions(String resourceKey, String name, diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolder.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolder.java index b19b6f9d0e3c..7180ecdf4893 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolder.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolder.java @@ -70,6 +70,16 @@ public void addThrottledAPIKey(String key, Long value){ throttledAPIKeysMap.put(key,value); } + private static final ThrottleDataHolder instance = new ThrottleDataHolder(); + + private ThrottleDataHolder() { + + } + + public static ThrottleDataHolder getInstance() { + return instance; + } + public void addThrottledApiConditions(String key, String conditionKey, List conditionValue) { Map> conditionMap; diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/handlers/throttling/ThrottleHandlerTest.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/handlers/throttling/ThrottleHandlerTest.java index 3b30119d2692..475e9f4acb7b 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/handlers/throttling/ThrottleHandlerTest.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/handlers/throttling/ThrottleHandlerTest.java @@ -122,7 +122,7 @@ public void init() { @Test public void testDoNotThrottleWhenMsgIsAResponseAndAuthCtxNotAvailable() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); @@ -133,7 +133,7 @@ public void testDoNotThrottleWhenMsgIsAResponseAndAuthCtxNotAvailable() { @Test public void testSubscriptionLevelThrottlingInitWhenThrottleCtxIsNull() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); @@ -145,7 +145,7 @@ public void testSubscriptionLevelThrottlingInitWhenThrottleCtxIsNull() { @Test public void testSubscriptionLevelThrottlingInitialization() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); @@ -160,7 +160,7 @@ public void testSubscriptionLevelThrottlingInitialization() { @Test public void testMsgThrottleOutWhenBlockingConditionsAreSatisfied() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); @@ -181,7 +181,7 @@ public void testMsgThrottleOutWhenBlockingConditionsAreSatisfied() { @Test public void testMsgThrottleContinueWhenAPITierIsNotAvailable() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); @@ -196,7 +196,7 @@ public void testMsgThrottleContinueWhenAPITierIsNotAvailable() { @Test public void testMsgDoContinueWhenAllThrottlingLevelsAreNotThrolled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ServiceReferenceHolder.getInstance().setThrottleDataPublisher(new ThrottleDataPublisher()); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -214,7 +214,7 @@ public void testMsgDoContinueWhenAllThrottlingLevelsAreNotThrolled() { @Test public void testMsgDoThrottleWhenUserLevelThrottlingIsTriggerred() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -233,7 +233,7 @@ public void testMsgDoThrottleWhenUserLevelThrottlingIsTriggerred() { @Test public void testMsgThrottleOutWhenAPILevelIsThrottled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -261,7 +261,7 @@ public void testMsgThrottleOutWhenAPILevelIsThrottled() { @Test public void testMsgThrottleOutWhenResourceLevelIsThrottled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -289,7 +289,7 @@ public void testMsgThrottleOutWhenResourceLevelIsThrottled() { @Test public void testMsgThrottleOutWhenSubscriptionLevelIsThrottledAndStopOnQuotaReachIsEnabled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -311,12 +311,13 @@ public void testMsgThrottleOutWhenSubscriptionLevelIsThrottledAndStopOnQuotaReac //Should throttle out and discontinue message flow, when subscription level is throttled out //and stop on quota reach is enabled Assert.assertFalse(throttleHandler.handleRequest(messageContext)); + throttleDataHolder.removeThrottleData(subscriptionLevelThrottleKey); } @Test public void testMsgContinueWhenSubscriptionLevelIsThrottledAndStopOnQuotaReachIsDisabled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -340,11 +341,12 @@ public void testMsgContinueWhenSubscriptionLevelIsThrottledAndStopOnQuotaReachIs //Though subscription level is throttled out, should continue the message flow, if stop on quota reach is //disabled Assert.assertTrue(throttleHandler.handleRequest(messageContext)); + throttleDataHolder.removeThrottleData(subscriptionLevelThrottleKey); } @Test public void testMsgThrottleOutWhenApplicationLevelIsThrottled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -365,11 +367,12 @@ public void testMsgThrottleOutWhenApplicationLevelIsThrottled() { //Should discontinue message flow, when application level is throttled Assert.assertFalse(throttleHandler.handleRequest(messageContext)); + throttleDataHolder.removeThrottleData(applicationLevelThrottleKey); } @Test public void testMsgThrottleOutWhenProductionHardThrottlingLimitsThrottled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator, accessInformation); @@ -399,7 +402,7 @@ public void testMsgThrottleOutWhenProductionHardThrottlingLimitsThrottled() { @Test public void testMsgThrottleOutWhenSandBoxHardThrottlingLimitsThrottled() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator, accessInformation); @@ -438,7 +441,7 @@ public void testMsgThrottleOutWhenSandBoxHardThrottlingLimitsThrottled() { @Test public void testMsgThrottleOutWhenCustomThrottlingLimitExceeded() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator, accessInformation); @@ -465,11 +468,13 @@ public void testMsgThrottleOutWhenCustomThrottlingLimitExceeded() { Assert.assertFalse(throttleHandler.handleRequest(messageContext)); throttleDataHolder.removeKeyTemplate("testKeyTemplate"); Assert.assertTrue(throttleHandler.handleRequest(messageContext)); + throttleDataHolder.removeThrottleData("testKeyTemplate"); + throttleDataHolder.removeKeyTemplate("$user"); } @Test public void testMsgThrottleOutWhenHittingSubscriptionLevelSpike() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator, accessInformation); @@ -500,7 +505,7 @@ public void testMsgThrottleOutWhenHittingSubscriptionLevelSpike() { @Test public void testHandleResponse() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -509,7 +514,7 @@ public void testHandleResponse() { @Test public void testCheckForStaledThrottleData() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ServiceReferenceHolder.getInstance().setThrottleDataPublisher(new ThrottleDataPublisher()); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator, accessInformation); @@ -533,11 +538,12 @@ public void testCheckForStaledThrottleData() { throttleDataHolder.addKeyTemplate("testKeyTemplate", "testKeyTemplateValue"); throttleDataHolder.addThrottleData("testKeyTemplate", System.currentTimeMillis() - 10000); Assert.assertTrue(throttleHandler.handleRequest(messageContext)); + throttleDataHolder.removeThrottleData("testKeyTemplate"); } @Test public void testMsgThrottleOutWithUserBlockingConditions() { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, throttleDataHolder, throttleEvaluator); MessageContext messageContext = TestUtils.getMessageContextWithAuthContext(apiContext, apiVersion); @@ -586,7 +592,7 @@ public void testMsgThrottleOutWithUserBlockingConditions() { @Test public void testHandleRequestForGraphQLSubscriptions() { - ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, new ThrottleDataHolder(), + ThrottleHandler throttleHandler = new ThrottlingHandlerWrapper(timer, ThrottleDataHolder.getInstance(), throttleEvaluator, accessInformation); Axis2MessageContext messageContext = Mockito.mock(Axis2MessageContext.class); org.apache.axis2.context.MessageContext axis2MessageContext = diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolderTestCase.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolderTestCase.java index a04bf35944cc..8f9805d75613 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolderTestCase.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/internal/ServiceReferenceHolderTestCase.java @@ -43,7 +43,6 @@ public void testServiceReferenceHolder() { serviceReferenceHolder.getThrottleDataHolder(); ThrottleDataHolder throttleDataHolder = Mockito.mock(ThrottleDataHolder.class); - serviceReferenceHolder.setThrottleDataHolder(throttleDataHolder); ConfigurationContextService cfgCtxService = Mockito.mock(ConfigurationContextService.class); serviceReferenceHolder.setConfigurationContextService(cfgCtxService); diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolderTest.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolderTest.java index 029d06a647d0..569b47552bf6 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolderTest.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/ThrottleDataHolderTest.java @@ -30,7 +30,7 @@ public class ThrottleDataHolderTest { public void addThrottleDataFromMap() throws Exception { Map map = new HashMap<>(); map.put("/api/1.0.0",System.currentTimeMillis()); - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); throttleDataHolder.addThrottleDataFromMap(map); throttleDataHolder.removeThrottleData("/api/1.0.0"); } @@ -38,7 +38,7 @@ public void addThrottleDataFromMap() throws Exception { @Test public void removeThrottledAPIKey() throws Exception { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); throttleDataHolder.addThrottledAPIKey("/api/1.0.0",System.currentTimeMillis()); throttleDataHolder.removeThrottledAPIKey("/api/1.0.0"); } @@ -46,7 +46,7 @@ public void removeThrottledAPIKey() throws Exception { @Test public void addBlockingCondition() throws Exception { - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); throttleDataHolder.addAPIBlockingCondition("/api1/1.0.0","enabled"); throttleDataHolder.removeAPIBlockingCondition("/api1/1.0.0"); throttleDataHolder.addApplicationBlockingCondition("admin:DefaultApplication","enabled"); diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/BlockingConditionRetrieverTest.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/BlockingConditionRetrieverTest.java index d4d48a0cb8ad..c3a4e4332ba1 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/BlockingConditionRetrieverTest.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/BlockingConditionRetrieverTest.java @@ -63,7 +63,7 @@ public void run() throws Exception { eventHubConfigurationDto.setPassword("admin".toCharArray()); eventHubConfigurationDto.setEnabled(true); eventHubConfigurationDto.setServiceUrl("http://localhost:18083/internal/data/v1"); - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); BlockingConditionRetriever blockingConditionRetriever = new BlockingConditionRetrieverWrapper(eventHubConfigurationDto, throttleDataHolder); blockingConditionRetriever.run(); diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/KeyTemplateRetrieverTest.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/KeyTemplateRetrieverTest.java index 8f0f5f693018..f5fcf4f7ad71 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/KeyTemplateRetrieverTest.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/test/java/org/wso2/carbon/apimgt/gateway/throttling/util/KeyTemplateRetrieverTest.java @@ -68,7 +68,7 @@ public void run() throws Exception { eventHubConfigurationDto.setPassword("admin".toCharArray()); eventHubConfigurationDto.setEnabled(true); eventHubConfigurationDto.setServiceUrl("http://localhost:18084/internal/data/v1"); - ThrottleDataHolder throttleDataHolder = new ThrottleDataHolder(); + ThrottleDataHolder throttleDataHolder = ThrottleDataHolder.getInstance(); KeyTemplateRetriever keyTemplateRetriever = new KeyTemplateRetrieverWrapper(eventHubConfigurationDto, throttleDataHolder); keyTemplateRetriever.run();