forked from I2P_Developers/i2p.i2p
getSession() cannot be null
This commit is contained in:
@@ -255,9 +255,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
newManager = true;
|
newManager = true;
|
||||||
} else {
|
} else {
|
||||||
I2PSession sess = sockMgr.getSession();
|
I2PSession sess = sockMgr.getSession();
|
||||||
if (sess == null) {
|
if (sess.isClosed() &&
|
||||||
newManager = true;
|
|
||||||
} else if (sess.isClosed() &&
|
|
||||||
Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.closeOnIdle")) &&
|
Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.closeOnIdle")) &&
|
||||||
Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.newDestOnResume"))) {
|
Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.newDestOnResume"))) {
|
||||||
// build a new socket manager and a new dest if the session is closed.
|
// build a new socket manager and a new dest if the session is closed.
|
||||||
@@ -317,7 +315,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
Log _log = tunnel.getContext().logManager().getLog(I2PTunnelClientBase.class);
|
Log _log = tunnel.getContext().logManager().getLog(I2PTunnelClientBase.class);
|
||||||
if (socketManager != null) {
|
if (socketManager != null) {
|
||||||
I2PSession s = socketManager.getSession();
|
I2PSession s = socketManager.getSession();
|
||||||
if ( (s == null) || (s.isClosed()) ) {
|
if (s.isClosed()) {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info(tunnel.getClientOptions().getProperty("inbound.nickname") + ": Building a new socket manager since the old one closed [s=" + s + "]");
|
_log.info(tunnel.getClientOptions().getProperty("inbound.nickname") + ": Building a new socket manager since the old one closed [s=" + s + "]");
|
||||||
if (s != null)
|
if (s != null)
|
||||||
@@ -709,9 +707,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
}
|
}
|
||||||
if (!chained) {
|
if (!chained) {
|
||||||
I2PSession session = sockMgr.getSession();
|
I2PSession session = sockMgr.getSession();
|
||||||
if (session != null) {
|
getTunnel().removeSession(session);
|
||||||
getTunnel().removeSession(session);
|
|
||||||
}
|
|
||||||
} // else the app chaining to this one closes it!
|
} // else the app chaining to this one closes it!
|
||||||
}
|
}
|
||||||
l.log("Stopping client " + toString());
|
l.log("Stopping client " + toString());
|
||||||
|
@@ -922,7 +922,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
|
|||||||
// use existing session to look up for efficiency
|
// use existing session to look up for efficiency
|
||||||
verifySocketManager();
|
verifySocketManager();
|
||||||
I2PSession sess = sockMgr.getSession();
|
I2PSession sess = sockMgr.getSession();
|
||||||
if(sess != null && !sess.isClosed()) {
|
if(!sess.isClosed()) {
|
||||||
byte[] hData = Base32.decode(destination.substring(0, 52));
|
byte[] hData = Base32.decode(destination.substring(0, 52));
|
||||||
if(hData != null) {
|
if(hData != null) {
|
||||||
if(_log.shouldLog(Log.INFO)) {
|
if(_log.shouldLog(Log.INFO)) {
|
||||||
|
@@ -28,6 +28,10 @@ import net.i2p.data.Destination;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface I2PSocketManager {
|
public interface I2PSocketManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the session, non-null
|
||||||
|
*/
|
||||||
public I2PSession getSession();
|
public I2PSession getSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -65,10 +65,10 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
|||||||
* This is what I2PSocketManagerFactory.createManager() returns.
|
* This is what I2PSocketManagerFactory.createManager() returns.
|
||||||
* Direct instantiation by others is deprecated.
|
* Direct instantiation by others is deprecated.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context non-null
|
||||||
* @param session
|
* @param session non-null
|
||||||
* @param opts
|
* @param opts may be null
|
||||||
* @param name
|
* @param name non-null
|
||||||
*/
|
*/
|
||||||
public I2PSocketManagerFull(I2PAppContext context, I2PSession session, Properties opts, String name) {
|
public I2PSocketManagerFull(I2PAppContext context, I2PSession session, Properties opts, String name) {
|
||||||
_context = context;
|
_context = context;
|
||||||
@@ -103,6 +103,9 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
|||||||
return curOpts;
|
return curOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the session, non-null
|
||||||
|
*/
|
||||||
public I2PSession getSession() {
|
public I2PSession getSession() {
|
||||||
return _session;
|
return _session;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user