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
b3ba7e16
authored
Sep 01, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Close DefaultHttpDataSource connections quietly.
parent
10badcc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
library/src/main/java/com/google/android/exoplayer/upstream/DefaultHttpDataSource.java
library/src/main/java/com/google/android/exoplayer/upstream/DefaultHttpDataSource.java
View file @
b3ba7e16
...
...
@@ -59,7 +59,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
public
static
final
int
DEFAULT_READ_TIMEOUT_MILLIS
=
8
*
1000
;
private
static
final
int
MAX_REDIRECTS
=
20
;
// Same limit as okhttp.
private
static
final
String
TAG
=
"HttpDataSource"
;
private
static
final
String
TAG
=
"
Default
HttpDataSource"
;
private
static
final
Pattern
CONTENT_RANGE_HEADER
=
Pattern
.
compile
(
"^bytes (\\d+)-(\\d+)/(\\d+)$"
);
private
static
final
AtomicReference
<
byte
[]>
skipBufferReference
=
new
AtomicReference
<>();
...
...
@@ -198,7 +198,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
try
{
responseCode
=
connection
.
getResponseCode
();
}
catch
(
IOException
e
)
{
closeConnection
();
closeConnection
Quietly
();
throw
new
HttpDataSourceException
(
"Unable to connect to "
+
dataSpec
.
uri
.
toString
(),
e
,
dataSpec
);
}
...
...
@@ -206,14 +206,14 @@ public class DefaultHttpDataSource implements HttpDataSource {
// Check for a valid response code.
if
(
responseCode
<
200
||
responseCode
>
299
)
{
Map
<
String
,
List
<
String
>>
headers
=
connection
.
getHeaderFields
();
closeConnection
();
closeConnection
Quietly
();
throw
new
InvalidResponseCodeException
(
responseCode
,
headers
,
dataSpec
);
}
// Check for a valid content type.
String
contentType
=
connection
.
getContentType
();
if
(
contentTypePredicate
!=
null
&&
!
contentTypePredicate
.
evaluate
(
contentType
))
{
closeConnection
();
closeConnection
Quietly
();
throw
new
InvalidContentTypeException
(
contentType
,
dataSpec
);
}
...
...
@@ -239,7 +239,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
try
{
inputStream
=
connection
.
getInputStream
();
}
catch
(
IOException
e
)
{
closeConnection
();
closeConnection
Quietly
();
throw
new
HttpDataSourceException
(
e
,
dataSpec
);
}
...
...
@@ -274,7 +274,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
}
}
finally
{
inputStream
=
null
;
closeConnection
();
closeConnection
Quietly
();
if
(
opened
)
{
opened
=
false
;
if
(
listener
!=
null
)
{
...
...
@@ -566,11 +566,15 @@ public class DefaultHttpDataSource implements HttpDataSource {
}
/**
* Closes the current connection, if there is one.
* Closes the current connection
quietly
, if there is one.
*/
private
void
closeConnection
()
{
private
void
closeConnection
Quietly
()
{
if
(
connection
!=
null
)
{
connection
.
disconnect
();
try
{
connection
.
disconnect
();
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"Unexpected error while disconnecting"
,
e
);
}
connection
=
null
;
}
}
...
...
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