Skip to content

Commit

Permalink
Cleanup should_remove_caller_context_from_cache_key experiment
Browse files Browse the repository at this point in the history
Reviewed By: amir-shalem

Differential Revision: D68826878

fbshipit-source-id: 11cd305cf63535fe65db93606e2006abd3087792
  • Loading branch information
Ilia Zaslavski authored and facebook-github-bot committed Jan 31, 2025
1 parent 4ff5385 commit 21a3f60
Showing 1 changed file with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ public class DefaultCacheKeyFactory implements CacheKeyFactory {

private static @Nullable DefaultCacheKeyFactory sInstance = null;

// Experiment with removing caller context from cache key. This should prevent leaking
// the caller context object by the cache key.
private static boolean sShouldRemoveCallerContextFromCacheKey = false;

protected DefaultCacheKeyFactory() {}

public static synchronized DefaultCacheKeyFactory getInstance() {
Expand All @@ -34,11 +30,6 @@ public static synchronized DefaultCacheKeyFactory getInstance() {
return sInstance;
}

public static void setShouldRemoveCallerContextFromCacheKey(
boolean shouldRemoveCallerContextFromCacheKey) {
sShouldRemoveCallerContextFromCacheKey = shouldRemoveCallerContextFromCacheKey;
}

@Override
public CacheKey getBitmapCacheKey(ImageRequest request, @Nullable Object callerContext) {
BitmapMemoryCacheKey cacheKey =
Expand All @@ -49,13 +40,7 @@ public CacheKey getBitmapCacheKey(ImageRequest request, @Nullable Object callerC
request.getImageDecodeOptions(),
null,
null);

if (sShouldRemoveCallerContextFromCacheKey) {
cacheKey.setCallerContext(null);
} else {
cacheKey.setCallerContext(callerContext);
}

cacheKey.setCallerContext(callerContext);
return cacheKey;
}

Expand All @@ -80,13 +65,7 @@ public CacheKey getPostprocessedBitmapCacheKey(
request.getImageDecodeOptions(),
postprocessorCacheKey,
postprocessorName);

if (sShouldRemoveCallerContextFromCacheKey) {
cacheKey.setCallerContext(null);
} else {
cacheKey.setCallerContext(callerContext);
}

cacheKey.setCallerContext(callerContext);
return cacheKey;
}

Expand Down

0 comments on commit 21a3f60

Please sign in to comment.