Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the EVCacheImpl cacheName is an empty string it should have the … #149

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions evcache-core/src/main/java/com/netflix/evcache/EVCacheImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.netflix.evcache.util.KeyHasher;
import com.netflix.evcache.util.RetryCount;
import com.netflix.evcache.util.Sneaky;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -119,7 +120,7 @@ public class EVCacheImpl implements EVCache, EVCacheImplMBean {
this._appName = appName;
this._cacheName = cacheName;

if(_cacheName != null && _cacheName.length() > 0) {
if(StringUtils.isNotEmpty(_cacheName)) {
for(int i = 0; i < cacheName.length(); i++) {
if(Character.isWhitespace(cacheName.charAt(i))){
throw new IllegalArgumentException("Cache Prefix ``" + cacheName + "`` contains invalid character at position " + i );
Expand All @@ -134,9 +135,11 @@ public class EVCacheImpl implements EVCache, EVCacheImplMBean {

tags = new ArrayList<Tag>(3);
EVCacheMetricsFactory.getInstance().addAppNameTags(tags, _appName);
if(_cacheName != null && _cacheName.length() > 0) tags.add(new BasicTag(EVCacheMetricsFactory.PREFIX, _cacheName));
if(StringUtils.isNotEmpty(_cacheName)) {
tags.add(new BasicTag(EVCacheMetricsFactory.PREFIX, _cacheName));
}

final String _metricName = (_cacheName == null) ? _appName : _appName + "." + _cacheName;
final String _metricName = StringUtils.isEmpty(_cacheName) ? _appName : _appName + "." + _cacheName;
_metricPrefix = _appName + "-";
this._poolManager = poolManager;
this._pool = poolManager.getEVCacheClientPool(_appName);
Expand All @@ -145,7 +148,7 @@ public class EVCacheImpl implements EVCache, EVCacheImplMBean {
_zoneFallbackFP = propertyRepository.get(_metricName + ".fallback.zone", Boolean.class).orElseGet(_appName + ".fallback.zone").orElse(true);
_bulkZoneFallbackFP = propertyRepository.get(_appName + ".bulk.fallback.zone", Boolean.class).orElse(true);
_bulkPartialZoneFallbackFP = propertyRepository.get(_appName+ ".bulk.partial.fallback.zone", Boolean.class).orElse(true);
if(_cacheName == null) {
if(StringUtils.isEmpty(_cacheName)) {
_useInMemoryCache = propertyRepository.get(_appName + ".use.inmemory.cache", Boolean.class).orElseGet("evcache.use.inmemory.cache").orElse(false);
} else {
_useInMemoryCache = propertyRepository.get(_appName + "." + _cacheName + ".use.inmemory.cache", Boolean.class).orElseGet(_appName + ".use.inmemory.cache").orElseGet("evcache.use.inmemory.cache").orElse(false);
Expand Down Expand Up @@ -207,7 +210,7 @@ EVCacheKey getEVCacheKey(final String key) {
}

final String canonicalKey;
if (this._cacheName == null) {
if (StringUtils.isEmpty(this._cacheName)) {
canonicalKey = key;
} else {
final int keyLength = _cacheName.length() + 1 + key.length();
Expand Down
Loading