mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Fix missing closes of Closeables caught by StrictMode
This commit is contained in:
parent
dbe01a17d2
commit
d71cbe344a
@ -244,10 +244,20 @@ public class NvHTTP {
|
|||||||
response = httpClient.newCall(request).execute();
|
response = httpClient.newCall(request).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResponseBody body = response.body();
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
return response.body();
|
return body;
|
||||||
}
|
}
|
||||||
else if (response.code() == 404) {
|
|
||||||
|
// Unsuccessful, so close the response body
|
||||||
|
try {
|
||||||
|
if (body != null) {
|
||||||
|
body.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {}
|
||||||
|
|
||||||
|
if (response.code() == 404) {
|
||||||
throw new FileNotFoundException(url);
|
throw new FileNotFoundException(url);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -267,24 +277,30 @@ public class NvHTTP {
|
|||||||
if (verbose) {
|
if (verbose) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scanner s = new Scanner(resp.byteStream());
|
StringBuilder strb = new StringBuilder();
|
||||||
|
try {
|
||||||
String str = "";
|
Scanner s = new Scanner(resp.byteStream());
|
||||||
while (s.hasNext()) {
|
try {
|
||||||
str += s.next() + " ";
|
while (s.hasNext()) {
|
||||||
|
strb.append(s.next());
|
||||||
|
strb.append(' ');
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
resp.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
s.close();
|
|
||||||
resp.close();
|
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
LimeLog.info(url+" -> "+str);
|
LimeLog.info(url+" -> "+strb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return strb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerVersion(String serverInfo) throws XmlPullParserException, IOException {
|
public String getServerVersion(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user