You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think cancel's lines should be the other way around. Think about a case where:
loadData connects to remote endpoint (let's call this conn).
DataFetcher implements cancel properly, i.e.interrupts the connection being initiated in conn.
The interruption throws an exception from conn which is then caught inside loadData.
Which then results in an immediate return x. Now we're back in decodeSourcedata having the value x and isCancelled may not yet be set to true, because who knows how fast fetcher.cancel() returns (it's another thread I couldn't see any sync around here).
This in the end leads to data/x being handed to decodeFromSourceData. Once data/x escapes the scope of decodeSource it will be handed to sourceDecoder or cacheEncoder and the whole lifecycle will follow through even though
isCancelled should have been true before decodeFromSourceData is called. Also data/x may be corrupted because of interruption.
EngineRunnable will however catch this and just plain recycle our hard-en/de-coded resource because isCancelled is set first in its cancel.
The above may be intentional though to fill the cache (even if the request can cleared), but it looks to me it only works if cancel is not implemented.
The text was updated successfully, but these errors were encountered:
Glide Version/Integration library (if any): 3.5.2/3.6.0-SNAPSHOT
Issue details/Repro steps: found this while researching a response:
I think
cancel
's lines should be the other way around. Think about a case where:loadData
connects to remote endpoint (let's call thisconn
).cancel
properly, i.e.interrupts the connection being initiated inconn
.The interruption throws an exception from
conn
which is then caught insideloadData
.return x
. Now we're back indecodeSource
data
having the valuex
andisCancelled
may not yet be set totrue
, because who knows how fastfetcher.cancel()
returns (it's another thread I couldn't see any sync around here).data/x
being handed todecodeFromSourceData
. Oncedata/x
escapes the scope ofdecodeSource
it will be handed tosourceDecoder
orcacheEncoder
and the whole lifecycle will follow through even thoughisCancelled
should have been true beforedecodeFromSourceData
is called. Alsodata/x
may be corrupted because of interruption.EngineRunnable
will however catch this and just plain recycle our hard-en/de-coded resource becauseisCancelled
is set first in itscancel
.The above may be intentional though to fill the cache (even if the request can cleared), but it looks to me it only works if
cancel
is not implemented.The text was updated successfully, but these errors were encountered: