Skip to content

Commit 11b47ec

Browse files
authored
Merge pull request #150 from Netflix/revert-149-treat-empty-string-as-null
Revert "When the EVCacheImpl cacheName is an empty string it should have the …"
2 parents dc4b13b + 69281da commit 11b47ec

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Diff for: evcache-core/src/main/java/com/netflix/evcache/EVCacheImpl.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.netflix.evcache.util.KeyHasher;
3131
import com.netflix.evcache.util.RetryCount;
3232
import com.netflix.evcache.util.Sneaky;
33-
import org.apache.commons.lang3.StringUtils;
3433
import org.slf4j.Logger;
3534
import org.slf4j.LoggerFactory;
3635

@@ -120,7 +119,7 @@ public class EVCacheImpl implements EVCache, EVCacheImplMBean {
120119
this._appName = appName;
121120
this._cacheName = cacheName;
122121

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

136135
tags = new ArrayList<Tag>(3);
137136
EVCacheMetricsFactory.getInstance().addAppNameTags(tags, _appName);
138-
if(StringUtils.isNotEmpty(_cacheName)) {
139-
tags.add(new BasicTag(EVCacheMetricsFactory.PREFIX, _cacheName));
140-
}
137+
if(_cacheName != null && _cacheName.length() > 0) tags.add(new BasicTag(EVCacheMetricsFactory.PREFIX, _cacheName));
141138

142-
final String _metricName = StringUtils.isEmpty(_cacheName) ? _appName : _appName + "." + _cacheName;
139+
final String _metricName = (_cacheName == null) ? _appName : _appName + "." + _cacheName;
143140
_metricPrefix = _appName + "-";
144141
this._poolManager = poolManager;
145142
this._pool = poolManager.getEVCacheClientPool(_appName);
@@ -148,7 +145,7 @@ public class EVCacheImpl implements EVCache, EVCacheImplMBean {
148145
_zoneFallbackFP = propertyRepository.get(_metricName + ".fallback.zone", Boolean.class).orElseGet(_appName + ".fallback.zone").orElse(true);
149146
_bulkZoneFallbackFP = propertyRepository.get(_appName + ".bulk.fallback.zone", Boolean.class).orElse(true);
150147
_bulkPartialZoneFallbackFP = propertyRepository.get(_appName+ ".bulk.partial.fallback.zone", Boolean.class).orElse(true);
151-
if(StringUtils.isEmpty(_cacheName)) {
148+
if(_cacheName == null) {
152149
_useInMemoryCache = propertyRepository.get(_appName + ".use.inmemory.cache", Boolean.class).orElseGet("evcache.use.inmemory.cache").orElse(false);
153150
} else {
154151
_useInMemoryCache = propertyRepository.get(_appName + "." + _cacheName + ".use.inmemory.cache", Boolean.class).orElseGet(_appName + ".use.inmemory.cache").orElseGet("evcache.use.inmemory.cache").orElse(false);
@@ -210,7 +207,7 @@ EVCacheKey getEVCacheKey(final String key) {
210207
}
211208

212209
final String canonicalKey;
213-
if (StringUtils.isEmpty(this._cacheName)) {
210+
if (this._cacheName == null) {
214211
canonicalKey = key;
215212
} else {
216213
final int keyLength = _cacheName.length() + 1 + key.length();

0 commit comments

Comments
 (0)