<p dir="auto">Dear development team,</p>
<p dir="auto">I'm using Glide to display product images in my app, e.g. on product detail page:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Glide.with( context )
         .load( url )
         .thumbnail( Glide.with( context )
            .load( placeholderResId )
            .apply( new RequestOptions()
               .centerCrop() ) )
         .into( productImageView );"><pre class="notranslate"><code class="notranslate">Glide.with( context )
         .load( url )
         .thumbnail( Glide.with( context )
            .load( placeholderResId )
            .apply( new RequestOptions()
               .centerCrop() ) )
         .into( productImageView );
</code></pre></div>
<p dir="auto">The caching mechanism of this library is really great to reduce the used bandwidth of the user, but now I have some problem where I need your help:</p>
<blockquote>
<p dir="auto">Given product detail page is displayed along with a product image.<br>
When user deletes product image<br>
and reopens product detail page<br>
Then product image should not be visible anymore (placeholder should be shown).</p>
</blockquote>
<p dir="auto"><strong>Problem:</strong><br>
Currently the product image will be loaded from the cache and is displayed to the user which is not expected.</p>
<p dir="auto">I would like to have the feature to delete a single image in the cache. But I found out, this is not possible.<br>
I found this <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="96775800" data-permission-text="Title is private" data-url="https://github.com/bumptech/glide/issues/552" data-hovercard-type="issue" data-hovercard-url="/bumptech/glide/issues/552/hovercard" href="https://github.com/bumptech/glide/issues/552">#552</a> and decided to go with the 1st solution, although it has some disadvantages for the user (deletion of product images is very rare).</p>
<p dir="auto">Calling <code class="notranslate">Glide.get( getApplicationContext() ).clearDiskCache();</code> is not sufficient, because the image could still be in the memory. So I have to call <code class="notranslate">Glide.get( getApplicationContext() ).clearMemory();</code> as well. But when I want to open the product detail page again, I get the following error message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="java.lang.IllegalStateException: cache is closed
                                        at com.bumptech.glide.disklrucache.DiskLruCache.checkNotClosed(DiskLruCache.java:620)
                                        at com.bumptech.glide.disklrucache.DiskLruCache.get(DiskLruCache.java:409)
                                        at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.get(DiskLruCacheWrapper.java:75)
                                        at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:62)
                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298)
                                        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:265)
                                        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229)
                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                        at java.lang.Thread.run(Thread.java:764)
                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)"><pre class="notranslate"><code class="notranslate">java.lang.IllegalStateException: cache is closed
                                        at com.bumptech.glide.disklrucache.DiskLruCache.checkNotClosed(DiskLruCache.java:620)
                                        at com.bumptech.glide.disklrucache.DiskLruCache.get(DiskLruCache.java:409)
                                        at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.get(DiskLruCacheWrapper.java:75)
                                        at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:62)
                                        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298)
                                        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:265)
                                        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229)
                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                                        at java.lang.Thread.run(Thread.java:764)
                                        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
</code></pre></div>
<p dir="auto">What do I need to do to "reinitialize" Glide? Or do you have another approach to the problem?<br>
Thanks<br>
Ben</p>

<p dir="auto"><strong>Glide Version</strong>: 4.3.1</p>

<p dir="auto"><strong>Integration libraries</strong>: OkHttp3</p>

<p dir="auto"><strong>Device/Android Version</strong>: Nexus 5X</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>:</p>

<p dir="auto"><strong>Glide load line / <code class="notranslate">GlideModule</code> (if any) / list Adapter code (if any)</strong>:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Glide.with..."><pre class="notranslate"><span class="pl-smi">Glide</span>.<span class="pl-smi">with</span>...</pre></div>

<p dir="auto"><strong>Layout XML</strong>:</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;FrameLayout xmlns:android=&quot;..."><pre class="notranslate">&lt;<span class="pl-ent">FrameLayout</span> <span class="pl-e">xmlns</span><span class="pl-e">:</span><span class="pl-e">android</span>=<span class="pl-s"><span class="pl-pds">"</span>...</span></pre></div>

<p dir="auto"><strong>Stack trace / LogCat</strong>:</p>
<div class="highlight highlight-source-ruby notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="paste stack trace and/or log here"><pre class="notranslate"><span class="pl-en">paste</span> <span class="pl-en">stack</span> <span class="pl-en">trace</span> <span class="pl-k">and</span>/<span class="pl-en">or</span> <span class="pl-en">log</span> <span class="pl-en">here</span></pre></div>
<p dir="auto"><strong>Glide Version</strong>:4.2.0 and before</p>

<p dir="auto"><strong>Integration libraries</strong>:OkHttp3</p>

<p dir="auto"><strong>Device/Android Version</strong>:All</p>

<p dir="auto"><strong>Issue details / Repro steps / Use case background</strong>:<br>
1.Clear App Cache from system setting<br>
2.Then call GlideApp.get(context).clearDiskCache() , that will cause a exception<br>
log:<br>
<code class="notranslate">W/DiskLruCacheWrapper: Unable to clear disk cache java.io.IOException: not a readable directory: /data/data/com.paisheng.example.pslib/cache/image_manager_disk_cache at com.bumptech.glide.disklrucache.Util.deleteContents(Util.java:55) at com.bumptech.glide.disklrucache.DiskLruCache.delete(DiskLruCache.java:660) at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.clear(DiskLruCacheWrapper.java:143) at com.bumptech.glide.load.engine.Engine.clearDiskCache(Engine.java:326) at com.bumptech.glide.Glide.clearDiskCache(Glide.java:498)</code><br>
3.Then call GlideApp.with(context).load(url).into(iv) , that will cause a exception<br>
log:<br>
<code class="notranslate">E/GlideExecutor: Request threw uncaught throwable java.lang.IllegalStateException: cache is closed at com.bumptech.glide.disklrucache.DiskLruCache.checkNotClosed(DiskLruCache.java:620) at com.bumptech.glide.disklrucache.DiskLruCache.get(DiskLruCache.java:409) at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.get(DiskLruCacheWrapper.java:75) at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:62) at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:293) at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:260) at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:386)</code></p>