correct a null pointer exception check before it gets caught and logged as an error

This commit is contained in:
mkvore-commit
2009-05-10 20:23:08 +00:00
parent 85382863d2
commit bc7a963f5c
3 changed files with 16 additions and 10 deletions

View File

@ -350,12 +350,12 @@ public class SAMv3Handler extends SAMv1Handler
_log.debug("Stop request found");
break;
}
msg = DataHelper.readLine(in).trim();
if (msg == null) {
_log.debug("Connection closed by client");
String line = DataHelper.readLine(in) ;
if (line==null) {
_log.debug("Connection closed by client (line read : null)");
break;
}
msg = line.trim();
if (_log.shouldLog(Log.DEBUG)) {
_log.debug("New message received: [" + msg + "]");

View File

@ -264,12 +264,12 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
public void run()
{
while (session.socketServer!=null) {
while (session.getSocketServer()!=null) {
// wait and accept a connection from I2P side
I2PSocket i2ps = null ;
try {
i2ps = session.socketServer.accept();
i2ps = session.getSocketServer().accept();
} catch (Exception e) {}
if (i2ps==null) {
@ -361,8 +361,14 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
}
}
public I2PServerSocket getSocketServer()
{
synchronized ( this.socketServerLock ) {
return this.socketServer ;
}
}
/**
*
* stop Forwarding Incoming connection coming from I2P
* @param props
* @throws SAMException
* @throws InterruptedIOException
@ -382,6 +388,7 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
}
server = this.socketServer ;
this.socketServer = null ;
_log.debug("nulling socketServer in stopForwardingIncoming. Object " + this );
}
try {
server.close();
@ -400,5 +407,4 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
{
throw new DataFormatException(null);
}
}

View File

@ -73,8 +73,8 @@ public class MessageHandler implements I2PSessionListener {
* @param session that has been terminated
*/
public void disconnected(I2PSession session) {
if (_log.shouldLog(Log.ERROR))
_log.error("I2PSession disconnected");
if (_log.shouldLog(Log.WARN))
_log.warn("I2PSession disconnected");
_manager.disconnectAllHard();
List listeners = null;