Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f8b85739
authored
Dec 04, 2018
by
olly
Committed by
Oliver Woodman
Dec 05, 2018
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix race condition that could cause downloader not to be canceled
PiperOrigin-RevId: 224048465
parent
5bbe3ae7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
View file @
f8b85739
...
...
@@ -565,7 +565,7 @@ public final class DownloadManager {
*/
@TargetState
private
volatile
int
targetState
;
@MonotonicNonNull
private
volatile
Downloader
downloader
;
@MonotonicNonNull
private
Downloader
downloader
;
@MonotonicNonNull
private
Thread
thread
;
@MonotonicNonNull
private
Throwable
error
;
...
...
@@ -624,6 +624,7 @@ public final class DownloadManager {
state
=
STATE_STARTED
;
targetState
=
STATE_COMPLETED
;
downloadManager
.
onTaskStateChange
(
this
);
downloader
=
downloaderFactory
.
createDownloader
(
action
);
thread
=
new
Thread
(
this
);
thread
.
start
();
}
...
...
@@ -648,11 +649,7 @@ public final class DownloadManager {
private
void
stopDownloadThread
(
@TargetState
int
targetState
)
{
this
.
targetState
=
targetState
;
// TODO: The possibility of downloader being null here may prevent the download thread from
// stopping in a timely way. Fix this.
if
(
downloader
!=
null
)
{
downloader
.
cancel
();
}
Assertions
.
checkNotNull
(
downloader
).
cancel
();
Assertions
.
checkNotNull
(
thread
).
interrupt
();
}
...
...
@@ -675,7 +672,6 @@ public final class DownloadManager {
logd
(
"Task is started"
,
this
);
Throwable
error
=
null
;
try
{
downloader
=
downloaderFactory
.
createDownloader
(
action
);
if
(
action
.
isRemoveAction
)
{
downloader
.
remove
();
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment