Bug fix: crash when validating account

This commit is contained in:
khanhduytran0 2020-12-08 12:10:46 +07:00
parent 2d67fc2ab7
commit 88cf0d3cad

View File

@ -34,20 +34,23 @@ public class YggdrasilAuthenticator {
if (os != null) {
os.close();
}
int statusCode = conn.getResponseCode();
if (statusCode != 200) {
is = conn.getErrorStream();
} else {
is = conn.getInputStream();
}
IOUtils.copy(is, bos);
if (is != null) {
IOUtils.copy(is, bos);
try {
is.close();
} catch (Exception e) {
throw e;
}
}
String outString = new String(bos.toByteArray(), Charset.forName("UTF-8"));
if (statusCode == 200 || statusCode == 204){
Log.i("Result", "Task " + endpoint + " successful");
@ -58,6 +61,7 @@ public class YggdrasilAuthenticator {
} else {
Log.i("Result", "Task " + endpoint + " failure");
}
if (responseClass == null) {
return new NetworkResponse(statusCode, outString);
}