The BackgroundBlockCache contains a flaw where closing the file fails to shut down the background data-fetching thread.
Currently, the close() method merely discards the cache reference, leaving the ThreadPoolExecutor and its pending download tasks actively running in the background. This oversight wastes network and memory capacity on a closed file and can cause a continuous buildup of dangling threads that might eventually crash or hang the application.
To resolve this, the cache class needs a dedicated shutdown method to explicitly cancel any active futures and terminate the executor, and this new teardown logic must be invoked directly inside the close() method before the cache object is dropped.
The
BackgroundBlockCachecontains a flaw where closing the file fails to shut down the background data-fetching thread.Currently, the close() method merely discards the cache reference, leaving the ThreadPoolExecutor and its pending download tasks actively running in the background. This oversight wastes network and memory capacity on a closed file and can cause a continuous buildup of dangling threads that might eventually crash or hang the application.
To resolve this, the cache class needs a dedicated shutdown method to explicitly cancel any active futures and terminate the executor, and this new teardown logic must be invoked directly inside the close() method before the cache object is dropped.