diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/RedisBaseDistributedCountManager.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/RedisBaseDistributedCountManager.java index a727e9065216..010e909860d5 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/RedisBaseDistributedCountManager.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/RedisBaseDistributedCountManager.java @@ -145,7 +145,7 @@ public long asyncGetAndAddCounter(String key, long value) { Response incrementedValue = transaction.incrBy(key, value); transaction.exec(); - if (currentValue != null) { + if (currentValue != null && currentValue.get() != null) { current = Long.parseLong(currentValue.get()); } if (log.isDebugEnabled()) { @@ -177,7 +177,7 @@ public long asyncGetAndAlterCounter(String key, long value) { Response incrementedValue = transaction.incrBy(key, value); transaction.exec(); - if (currentValue != null) { + if (currentValue != null && currentValue.get() != null) { current = Long.parseLong(currentValue.get()); } if (log.isDebugEnabled()) { diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/APIHandlerServiceComponent.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/APIHandlerServiceComponent.java index 4700304cab14..0190b06fe70e 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/APIHandlerServiceComponent.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/internal/APIHandlerServiceComponent.java @@ -126,11 +126,11 @@ protected void activate(ComponentContext context) { RedisConfig redisConfig = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration().getRedisConfig(); if (redisConfig.isRedisEnabled()) { + ServiceReferenceHolder.getInstance().setRedisPool(getJedisPool(redisConfig)); RedisBaseDistributedCountManager redisBaseDistributedCountManager = new RedisBaseDistributedCountManager(ServiceReferenceHolder.getInstance().getRedisPool()); context.getBundleContext().registerService(DistributedCounterManager.class, redisBaseDistributedCountManager, null); - ServiceReferenceHolder.getInstance().setRedisPool(getJedisPool(redisConfig)); } // Create caches for the super tenant diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java index e3f4cdd1e8a6..2fa9135c12c5 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIManagerConfiguration.java @@ -386,12 +386,19 @@ private void readChildElements(OMElement serverConfig, redisConfig.setRedisEnabled(true); redisConfig.setHost(redisHost.getText()); redisConfig.setPort(Integer.parseInt(redisPort.getText())); - if (redisUser != null && redisPassword != null && redisDatabaseId != null - && redisConnectionTimeout != null && redisIsSslEnabled != null) { + if (redisUser != null) { redisConfig.setUser(redisUser.getText()); + } + if (redisPassword != null) { redisConfig.setPassword(MiscellaneousUtil.resolve(redisPassword, secretResolver).toCharArray()); + } + if (redisDatabaseId != null) { redisConfig.setDatabaseId(Integer.parseInt(redisDatabaseId.getText())); + } + if (redisConnectionTimeout != null) { redisConfig.setConnectionTimeout(Integer.parseInt(redisConnectionTimeout.getText())); + } + if (redisIsSslEnabled != null) { redisConfig.setSslEnabled(Boolean.parseBoolean(redisIsSslEnabled.getText())); } if (propertiesElement !=null){