mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-06-20 16:00:29 +00:00
Handle expected EOF after closing in a different thread
This commit is contained in:
@ -18,6 +18,7 @@ public abstract class AbstractJsonList<T, E extends Exception> {
|
|||||||
protected final JSONTableScanner table;
|
protected final JSONTableScanner table;
|
||||||
protected HttpURLConnection httpConnection;
|
protected HttpURLConnection httpConnection;
|
||||||
protected JSONTokeniser json;
|
protected JSONTokeniser json;
|
||||||
|
protected boolean closed = false;
|
||||||
protected long rowCount = 0;
|
protected long rowCount = 0;
|
||||||
|
|
||||||
protected AbstractJsonList(ServalDHttpConnectionFactory httpConnector, JSONTableScanner table){
|
protected AbstractJsonList(ServalDHttpConnectionFactory httpConnector, JSONTableScanner table){
|
||||||
@ -88,6 +89,8 @@ public abstract class AbstractJsonList<T, E extends Exception> {
|
|||||||
json.consume(JSONTokeniser.Token.EOF);
|
json.consume(JSONTokeniser.Token.EOF);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (closed && tok == JSONTokeniser.Token.EOF)
|
||||||
|
return null;
|
||||||
if (rowCount != 0)
|
if (rowCount != 0)
|
||||||
JSONTokeniser.match(tok, JSONTokeniser.Token.COMMA);
|
JSONTokeniser.match(tok, JSONTokeniser.Token.COMMA);
|
||||||
else
|
else
|
||||||
@ -110,10 +113,11 @@ public abstract class AbstractJsonList<T, E extends Exception> {
|
|||||||
|
|
||||||
public void close() throws IOException
|
public void close() throws IOException
|
||||||
{
|
{
|
||||||
|
if (closed)
|
||||||
|
return;
|
||||||
|
closed = true;
|
||||||
httpConnection = null;
|
httpConnection = null;
|
||||||
if (json != null) {
|
if (json != null)
|
||||||
json.close();
|
json.close();
|
||||||
json = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user