Skip to content

Commit

Permalink
MGR-132 avoid NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Jan 13, 2022
1 parent d93367b commit 6841a8e
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/main/java/org/appng/application/manager/business/Cache.java
Expand Up @@ -122,11 +122,17 @@ public DataContainer getData(Site site, Application application, Environment env
int endIdx = pageable.getOffset() + pageable.getPageSize();
while (elements.hasNext()) {
javax.cache.Cache.Entry<java.lang.String, CachedResponse> entry = elements.next();
if (idx >= startIdx && idx < endIdx) {
cacheEntries.add(new CacheEntry(entry.getValue()));
}
if (idx++ >= endIdx) {
break;
CachedResponse cachedResponse = entry.getValue();
// entry may have been removed meanwhile
if (null != cachedResponse) {
if (idx >= startIdx && idx < endIdx) {
cacheEntries.add(new CacheEntry(cachedResponse));
}
if (idx++ >= endIdx) {
break;
}
} else {
endIdx++;
}
}

Expand All @@ -147,12 +153,15 @@ public DataContainer getData(Site site, Application application, Environment env
for (javax.cache.Cache.Entry<String, CachedResponse> entry : cache) {
String entryId = entry.getKey();
CachedResponse cachedResponse = entry.getValue();
boolean nameMatches = !filterName || FilenameUtils.wildcardMatch(
entryId.substring(entryId.indexOf('/')), entryName, IOCase.INSENSITIVE);
boolean typeMatches = !filterType || FilenameUtils
.wildcardMatch(cachedResponse.getContentType(), entryType, IOCase.INSENSITIVE);
if (nameMatches && typeMatches) {
cacheEntries.add(new CacheEntry(cachedResponse));
// entry may have been removed meanwhile
if (null != cachedResponse) {
boolean nameMatches = !filterName || FilenameUtils.wildcardMatch(
entryId.substring(entryId.indexOf('/')), entryName, IOCase.INSENSITIVE);
boolean typeMatches = !filterType || FilenameUtils
.wildcardMatch(cachedResponse.getContentType(), entryType, IOCase.INSENSITIVE);
if (nameMatches && typeMatches) {
cacheEntries.add(new CacheEntry(cachedResponse));
}
}
}

Expand Down

0 comments on commit 6841a8e

Please sign in to comment.