mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 15:11:03 +00:00
Check for null error streams
This commit is contained in:
parent
ce3f3dd387
commit
60c9d33a65
2 changed files with 12 additions and 6 deletions
|
@ -1218,11 +1218,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
InputStream inputStream = (status == HttpsURLConnection.HTTP_OK
|
||||
? urlConnection.getInputStream() : urlConnection.getErrorStream());
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
||||
if (inputStream != null) {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
response.append(line);
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
response.append(line);
|
||||
}
|
||||
|
||||
if (status == HttpsURLConnection.HTTP_FORBIDDEN) {
|
||||
// {"message":"API rate limit exceeded for ...","documentation_url":"https://developer.github.com/v3/#rate-limiting"}
|
||||
|
|
|
@ -215,7 +215,9 @@ public class DeepL {
|
|||
if (status != HttpsURLConnection.HTTP_OK) {
|
||||
String error = "Error " + status + ": " + connection.getResponseMessage();
|
||||
try {
|
||||
error += "\n" + Helper.readStream(connection.getErrorStream());
|
||||
InputStream is = connection.getErrorStream();
|
||||
if (is != null)
|
||||
error += "\n" + Helper.readStream(is);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
@ -257,7 +259,9 @@ public class DeepL {
|
|||
if (status != HttpsURLConnection.HTTP_OK) {
|
||||
String error = "Error " + status + ": " + connection.getResponseMessage();
|
||||
try {
|
||||
error += "\n" + Helper.readStream(connection.getErrorStream());
|
||||
InputStream is = connection.getErrorStream();
|
||||
if (is != null)
|
||||
error += "\n" + Helper.readStream(is);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue