Don't log stack trace in cache tests (#11610)

This commit is contained in:
Gregory Michael Travis 2024-11-21 08:22:41 +00:00 committed by GitHub
parent 76ad3475c8
commit 39a176e61b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -99,7 +99,7 @@ public class LRUCache<M> {
*/ */
private CacheResult<M> makeRequestAndCache(String cacheKey, ItemBuilder<M> itemBuilder) private CacheResult<M> makeRequestAndCache(String cacheKey, ItemBuilder<M> itemBuilder)
throws IOException, InterruptedException, ResponseTooLargeException { throws IOException, InterruptedException, ResponseTooLargeException {
assert !cache.containsKey(cacheKey); assert !cache.containsKey(cacheKey) : "Cache should not contain key " + cacheKey;
Item<M> item = itemBuilder.buildItem(); Item<M> item = itemBuilder.buildItem();
@ -135,7 +135,9 @@ public class LRUCache<M> {
return getResultForCacheEntry(cacheKey); return getResultForCacheEntry(cacheKey);
} catch (IOException e) { } catch (IOException e) {
logger.log( logger.log(
Level.WARNING, "Failure storing cache entry; will re-execute without caching: {}", e); Level.WARNING,
"Failure storing cache entry; will re-execute without caching: {}",
e.getMessage());
// Re-issue the request since we don't know if we've consumed any of the response. // Re-issue the request since we don't know if we've consumed any of the response.
Item<M> rerequested = itemBuilder.buildItem(); Item<M> rerequested = itemBuilder.buildItem();
return new CacheResult<>(rerequested.stream(), rerequested.metadata()); return new CacheResult<>(rerequested.stream(), rerequested.metadata());
@ -255,7 +257,8 @@ public class LRUCache<M> {
toRemove.add(mapEntry); toRemove.add(mapEntry);
totalSize -= mapEntry.getValue().size(); totalSize -= mapEntry.getValue().size();
} }
assert totalSize <= maxTotalCacheSize; assert totalSize <= maxTotalCacheSize
: "totalSize > maxTotalCacheSize (" + totalSize + " > " + maxTotalCacheSize + ")";
removeCacheEntries(toRemove); removeCacheEntries(toRemove);
} }

View File

@ -71,7 +71,7 @@ public class LRUCacheSettings {
"Unable to parse environment variable " "Unable to parse environment variable "
+ MAX_FILE_SIZE_ENV_VAR + MAX_FILE_SIZE_ENV_VAR
+ ": {}, falling back to default", + ": {}, falling back to default",
e); e.getMessage());
return DEFAULT_MAX_FILE_SIZE; return DEFAULT_MAX_FILE_SIZE;
} }
} }
@ -92,7 +92,7 @@ public class LRUCacheSettings {
"Unable to parse environment variable " "Unable to parse environment variable "
+ TOTAL_CACHE_SIZE_ENV_VAR + TOTAL_CACHE_SIZE_ENV_VAR
+ ": {}, falling back to default", + ": {}, falling back to default",
e); e.getMessage());
return new TotalCacheLimit.Percentage(DEFAULT_TOTAL_CACHE_SIZE_FREE_SPACE_PERCENTAGE); return new TotalCacheLimit.Percentage(DEFAULT_TOTAL_CACHE_SIZE_FREE_SPACE_PERCENTAGE);
} }
} }