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
6bf62770
authored
May 01, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make sure that the process dies if a loading task throws Error.
parent
1d528b80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
library/src/main/java/com/google/android/exoplayer/upstream/Loader.java
library/src/main/java/com/google/android/exoplayer/upstream/Loader.java
View file @
6bf62770
...
@@ -99,7 +99,8 @@ public final class Loader {
...
@@ -99,7 +99,8 @@ public final class Loader {
}
}
private
static
final
int
MSG_END_OF_SOURCE
=
0
;
private
static
final
int
MSG_END_OF_SOURCE
=
0
;
private
static
final
int
MSG_ERROR
=
1
;
private
static
final
int
MSG_IO_EXCEPTION
=
1
;
private
static
final
int
MSG_FATAL_ERROR
=
2
;
private
final
ExecutorService
downloadExecutorService
;
private
final
ExecutorService
downloadExecutorService
;
...
@@ -242,20 +243,30 @@ public final class Loader {
...
@@ -242,20 +243,30 @@ public final class Loader {
}
}
sendEmptyMessage
(
MSG_END_OF_SOURCE
);
sendEmptyMessage
(
MSG_END_OF_SOURCE
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
obtainMessage
(
MSG_
ERROR
,
e
).
sendToTarget
();
obtainMessage
(
MSG_
IO_EXCEPTION
,
e
).
sendToTarget
();
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
// The load was canceled.
// The load was canceled.
Assertions
.
checkState
(
loadable
.
isLoadCanceled
());
Assertions
.
checkState
(
loadable
.
isLoadCanceled
());
sendEmptyMessage
(
MSG_END_OF_SOURCE
);
sendEmptyMessage
(
MSG_END_OF_SOURCE
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// This should never happen, but handle it anyway.
// This should never happen, but handle it anyway.
Log
.
e
(
TAG
,
"Unexpected exception loading stream"
,
e
);
obtainMessage
(
MSG_IO_EXCEPTION
,
new
UnexpectedLoaderException
(
e
)).
sendToTarget
();
}
catch
(
Error
e
)
{
// We'd hope that the platform would kill the process if an Error is thrown here, but the
// executor may catch the error (b/20616433). Throw it here, but also pass and throw it from
// the handler thread so that the process dies even if the executor behaves in this way.
Log
.
e
(
TAG
,
"Unexpected error loading stream"
,
e
);
Log
.
e
(
TAG
,
"Unexpected error loading stream"
,
e
);
obtainMessage
(
MSG_ERROR
,
new
UnexpectedLoaderException
(
e
)).
sendToTarget
();
obtainMessage
(
MSG_FATAL_ERROR
,
e
).
sendToTarget
();
throw
e
;
}
}
}
}
@Override
@Override
public
void
handleMessage
(
Message
msg
)
{
public
void
handleMessage
(
Message
msg
)
{
if
(
msg
.
what
==
MSG_FATAL_ERROR
)
{
throw
(
Error
)
msg
.
obj
;
}
onFinished
();
onFinished
();
if
(
loadable
.
isLoadCanceled
())
{
if
(
loadable
.
isLoadCanceled
())
{
callback
.
onLoadCanceled
(
loadable
);
callback
.
onLoadCanceled
(
loadable
);
...
@@ -265,7 +276,7 @@ public final class Loader {
...
@@ -265,7 +276,7 @@ public final class Loader {
case
MSG_END_OF_SOURCE:
case
MSG_END_OF_SOURCE:
callback
.
onLoadCompleted
(
loadable
);
callback
.
onLoadCompleted
(
loadable
);
break
;
break
;
case
MSG_
ERROR
:
case
MSG_
IO_EXCEPTION
:
callback
.
onLoadError
(
loadable
,
(
IOException
)
msg
.
obj
);
callback
.
onLoadError
(
loadable
,
(
IOException
)
msg
.
obj
);
break
;
break
;
}
}
...
...
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