Swap order of closing streams to avoid deadlocking issue on android

This commit is contained in:
Jeremy Lakeman 2017-10-11 15:32:56 +10:30
parent ac43a629e6
commit bcb89d8351

View File

@ -108,6 +108,8 @@ public class JSONTokeniser {
private int _read() private int _read()
{ {
if (closed)
return -1;
int p = pushedChar; int p = pushedChar;
pushedChar = -1; pushedChar = -1;
if (p!=-1) if (p!=-1)
@ -128,6 +130,8 @@ public class JSONTokeniser {
private int _read(char[] buf, int offset, int length) private int _read(char[] buf, int offset, int length)
{ {
if (closed)
return -1;
if (length==0) if (length==0)
return 0; return 0;
@ -528,8 +532,8 @@ public class JSONTokeniser {
public void close() throws IOException public void close() throws IOException
{ {
closed = true; closed = true;
this.reader.close();
this.underlyingStream.close(); this.underlyingStream.close();
this.reader.close();
} }
} }