HTTPCLIENT-2277, regression: corrected wrong variant entry keys in cache hits returned by `BasicHttpCache#getVariants`
This commit is contained in:
parent
889a6bb085
commit
02f09c03f4
|
@ -179,9 +179,10 @@ class BasicHttpCache implements HttpCache {
|
|||
if (root != null && root.hasVariants()) {
|
||||
final List<CacheHit> variants = new ArrayList<>();
|
||||
for (final String variantKey : root.getVariants()) {
|
||||
final HttpCacheEntry variant = getInternal(variantKey + rootKey);
|
||||
final String variantCacheKey = variantKey + rootKey;
|
||||
final HttpCacheEntry variant = getInternal(variantCacheKey);
|
||||
if (variant != null) {
|
||||
variants.add(new CacheHit(hit.rootKey, variantKey, variant));
|
||||
variants.add(new CacheHit(rootKey, variantCacheKey, variant));
|
||||
}
|
||||
}
|
||||
return variants;
|
||||
|
|
|
@ -261,8 +261,10 @@ public class TestBasicHttpCache {
|
|||
|
||||
assertNotNull(variantMap);
|
||||
assertEquals(2, variantMap.size());
|
||||
MatcherAssert.assertThat(variantMap.get("{accept-encoding=gzip}"), HttpCacheEntryMatcher.equivalent(hit1.entry));
|
||||
MatcherAssert.assertThat(variantMap.get("{accept-encoding=identity}"), HttpCacheEntryMatcher.equivalent(hit2.entry));
|
||||
MatcherAssert.assertThat(variantMap.get("{accept-encoding=gzip}" + rootKey),
|
||||
HttpCacheEntryMatcher.equivalent(hit1.entry));
|
||||
MatcherAssert.assertThat(variantMap.get("{accept-encoding=identity}" + rootKey),
|
||||
HttpCacheEntryMatcher.equivalent(hit2.entry));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue