prevent race NPE http://forum.i2p/viewtopic.php?t=3066
This commit is contained in:
@ -134,9 +134,11 @@ public class I2CPMessageReader {
|
|||||||
public void cancelRunner() {
|
public void cancelRunner() {
|
||||||
_doRun = false;
|
_doRun = false;
|
||||||
_stayAlive = false;
|
_stayAlive = false;
|
||||||
if (_stream != null) {
|
// prevent race NPE
|
||||||
|
InputStream in = _stream;
|
||||||
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
_stream.close();
|
in.close();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
_log.error("Error closing the stream", ioe);
|
_log.error("Error closing the stream", ioe);
|
||||||
}
|
}
|
||||||
@ -164,6 +166,7 @@ public class I2CPMessageReader {
|
|||||||
_listener.disconnected(I2CPMessageReader.this);
|
_listener.disconnected(I2CPMessageReader.this);
|
||||||
cancelRunner();
|
cancelRunner();
|
||||||
} catch (OutOfMemoryError oom) {
|
} catch (OutOfMemoryError oom) {
|
||||||
|
// ooms seen here... maybe log and keep going?
|
||||||
throw oom;
|
throw oom;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.log(Log.CRIT, "Unhandled error reading I2CP stream", e);
|
_log.log(Log.CRIT, "Unhandled error reading I2CP stream", e);
|
||||||
|
Reference in New Issue
Block a user