Skip to content

Commit

Permalink
Catch URISyntaxError in MediaUrlResolver
Browse files Browse the repository at this point in the history
Certain platform implementation of HttpUrlConnection sometimes throw a
URISyntaxError, despite HttpUrlConnection not defining it as a throwable
exception, as part of its interface.

This CL fixes the issue.

Bug: 820130
Change-Id: I86602cf4a93fa8fccf19fbb4470e2cde48ba14b5
Reviewed-on: https://chromium-review.googlesource.com/957585
Reviewed-by: Anthony Berent <aberent@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543123}
  • Loading branch information
tguilbert-google authored and Commit Bot committed Mar 14, 2018
1 parent 1989515 commit 1438475
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLStreamHandler;
import java.util.Arrays;
Expand Down Expand Up @@ -190,6 +191,13 @@ protected MediaUrlResolver.Result doInBackground(Void... params) {
recordResultHistogram(RESOLVE_RESULT_HUC_EXCEPTION);
Log.e(TAG, "Threading issue with HUC, see https://crbug.com/754480", e);
uri = Uri.EMPTY;
} catch (RuntimeException e) {
if (e.getCause() instanceof URISyntaxException) {
Log.e(TAG, "Invalid URL format", e);
uri = Uri.EMPTY;
} else {
throw e;
}
} finally {
if (urlConnection != null) urlConnection.disconnect();
}
Expand Down

0 comments on commit 1438475

Please sign in to comment.