There is a caching of InputStream instances in VarCache.fileStreams and a usage of them on several places. This produces a lot of bugs because when you use an InputStream you read it and close it, but InputStream cannot be read after it had been closed.
The stream cache cannot be easily removed because streams could come from several places - file system, bytes array, resource from ContentProvider, resource from the zipped res folder, etc.
Solution minimizes the changes to the codebase. Several changes are introduced:
Replaced the InputStream with StreamProvider, which is not holding an InputStream instance but creating a new one when you call openStream().
Separated VarCache.registerFile into two different registerFile methods to remove the isResource parameter.
Background
There is a caching of
InputStream
instances inVarCache.fileStreams
and a usage of them on several places. This produces a lot of bugs because when you use anInputStream
you read it and close it, butInputStream
cannot be read after it had been closed.The stream cache cannot be easily removed because streams could come from several places - file system, bytes array, resource from
ContentProvider
, resource from the zipped res folder, etc.Solution minimizes the changes to the codebase. Several changes are introduced:
Replaced the
InputStream
withStreamProvider
, which is not holding anInputStream
instance but creating a new one when you callopenStream()
.Separated
VarCache.registerFile
into two differentregisterFile
methods to remove theisResource
parameter.Some minor readability improvements.