Commit 389faaaf authored by Mingyang Zhu's avatar Mingyang Zhu
Browse files

catch cache exception in client side

parent 4b502f03
......@@ -39,7 +39,7 @@
<aws.version>1.11.637</aws.version>
<deployment.environment>dev</deployment.environment>
<version.number>0.0.4-SNAPSHOT</version.number>
<osdu.oscorecommon.version>0.9.1</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.9.0-rc4</osdu.oscorecommon.version>
</properties>
<dependencies>
......
......@@ -37,7 +37,7 @@
<project.main.basedir>${project.parent.basedir}</project.main.basedir>
<springboot.version>2.1.7.RELEASE</springboot.version>
<osdu.corelibazure.version>0.9.0-rc1</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.9.1</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.9.0-rc4</osdu.oscorecommon.version>
<osdu.search-core.version>0.9.0-SNAPSHOT</osdu.search-core.version>
<spatial4j.version>0.7</spatial4j.version>
<jts-io-common.version>1.15.0</jts-io-common.version>
......
......@@ -41,7 +41,13 @@ public class CursorCacheImpl implements CursorCache {
@Override
public CursorSettings get(String s) {
return this.cache.getSuppressException(s, Optional.of(this.log));
CursorSettings cursorSettings = null;
try {
cursorSettings = this.cache.get(s);
} catch (Exception ex) {
this.log.error(String.format("Error getting key %s from redis: %s", s, ex));
}
return cursorSettings;
}
@Override
......
......@@ -14,8 +14,6 @@
package org.opengroup.osdu.search.provider.azure.cache.impl;
import javax.annotation.Resource;
import org.opengroup.osdu.azure.cache.ElasticCredentialsCache;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
......@@ -24,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.util.Optional;
import javax.annotation.Resource;
@Component("clusterSettingsCache")
@ConditionalOnProperty(value = "cache.provider", havingValue = "redis")
......@@ -43,7 +41,13 @@ public class ElasticCredentialsCacheImpl extends ElasticCredentialsCache {
@Override
public ClusterSettings get(String s) {
return this.cache.getSuppressException(s, Optional.of(this.log));
ClusterSettings cursorSettings = null;
try {
cursorSettings = this.cache.get(s);
} catch (Exception ex) {
this.log.error(String.format("Error getting key %s from redis: %s", s, ex));
}
return cursorSettings;
}
@Override
......
......@@ -48,7 +48,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.9.1</version>
<version>0.9.0-rc4</version>
</dependency>
<dependency>
......
......@@ -25,7 +25,7 @@
<properties>
<os-core-lib-ibm.version>0.9.0-SNAPSHOT</os-core-lib-ibm.version>
<start-class>org.opengroup.osdu.search.provider.ibm.app.SearchIBMApplication</start-class>
<osdu.oscorecommon.version>0.9.1</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.9.0-rc4</osdu.oscorecommon.version>
</properties>
......
......@@ -33,7 +33,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.9.1</version>
<version>0.9.0-rc4</version>
</dependency>
<dependency>
......
......@@ -15,25 +15,24 @@
package org.opengroup.osdu.search.service;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.model.entitlements.Acl;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.model.storage.RecordMetadata;
import org.opengroup.osdu.core.common.util.Crc32c;
import org.opengroup.osdu.core.common.model.entitlements.EntitlementsException;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsService;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.entitlements.Acl;
import org.opengroup.osdu.core.common.model.entitlements.EntitlementsException;
import org.opengroup.osdu.core.common.model.entitlements.Groups;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.storage.RecordMetadata;
import org.opengroup.osdu.core.common.util.Crc32c;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@Service
......@@ -137,7 +136,12 @@ public class EntitlementsAndCacheServiceImpl implements IEntitlementsExtensionSe
@Override
public Groups getGroups(DpsHeaders headers) {
String cacheKey = this.getGroupCacheKey(headers);
Groups groups = this.cache.getSuppressException(cacheKey, Optional.of(this.logger));
Groups groups = null;
try {
groups = this.cache.get(cacheKey);
} catch (Exception ex) {
this.logger.error(String.format("Error getting key %s from redis: %s", cacheKey, ex));
}
if (groups == null) {
IEntitlementsService service = this.factory.create(headers);
......
......@@ -191,12 +191,12 @@ public class EntitlementsAndCacheServiceImplTest {
// First call, getting groups from entitlements
assertEquals(MEMBER_EMAIL, this.sut.authorize(this.headers, "role2"));
when(this.cache.getSuppressException("NLdxKQ==", Optional.of(logger))).thenReturn(groups);
when(this.cache.get("NLdxKQ==")).thenReturn(groups);
// Second call, getting groups from cache
assertEquals(MEMBER_EMAIL, this.sut.authorize(this.headers, "role2"));
verify(this.entitlementService, times(1)).getGroups();
verify(this.cache, times(2)).getSuppressException("NLdxKQ==", Optional.of(logger));
verify(this.cache, times(2)).get("NLdxKQ==");
verify(this.cache, times(1)).put("NLdxKQ==", groups);
}
......@@ -410,4 +410,4 @@ public class EntitlementsAndCacheServiceImplTest {
List<RecordMetadata> result = this.sut.hasValidAccess(input, this.headers);
assertEquals(0, result.size());
}
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.9.1</version>
<version>0.9.0-rc4</version>
</dependency>
<dependency>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment