Commit 7bbfb9db authored by Florian Schmaus's avatar Florian Schmaus

Make conn final in LocalSession

and remove null checks.

Related to OF-855.
parent b1599c97
...@@ -134,8 +134,7 @@ public class HttpSession extends LocalClientSession { ...@@ -134,8 +134,7 @@ public class HttpSession extends LocalClientSession {
public HttpSession(PacketDeliverer backupDeliverer, String serverName, InetAddress address, public HttpSession(PacketDeliverer backupDeliverer, String serverName, InetAddress address,
StreamID streamID, long rid, HttpConnection connection) { StreamID streamID, long rid, HttpConnection connection) {
super(serverName, null, streamID); super(serverName, new HttpVirtualConnection(address), streamID);
conn = new HttpVirtualConnection(address);
this.isClosed = false; this.isClosed = false;
this.lastActivity = System.currentTimeMillis(); this.lastActivity = System.currentTimeMillis();
this.lastRequestID = rid; this.lastRequestID = rid;
......
...@@ -854,14 +854,7 @@ public class LocalClientSession extends LocalSession implements ClientSession { ...@@ -854,14 +854,7 @@ public class LocalClientSession extends LocalSession implements ClientSession {
@Override @Override
public void deliver(Packet packet) throws UnauthorizedException { public void deliver(Packet packet) throws UnauthorizedException {
if (conn != null) {
conn.deliver(packet); conn.deliver(packet);
} else {
// invalid session; clean up and retry delivery (offline)
Log.error("Failed to deliver packet to invalid session (no connection); will retry");
sessionManager.removeSession(this);
XMPPServer.getInstance().getPacketDeliverer().deliver(packet);
}
} }
@Override @Override
......
...@@ -302,7 +302,7 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C ...@@ -302,7 +302,7 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
@Override @Override
void deliver(Packet packet) throws UnauthorizedException { void deliver(Packet packet) throws UnauthorizedException {
if (conn != null && !conn.isClosed()) { if (!conn.isClosed()) {
conn.deliver(packet); conn.deliver(packet);
} }
} }
......
...@@ -611,7 +611,7 @@ public class LocalOutgoingServerSession extends LocalServerSession implements Ou ...@@ -611,7 +611,7 @@ public class LocalOutgoingServerSession extends LocalServerSession implements Ou
@Override @Override
void deliver(Packet packet) throws UnauthorizedException { void deliver(Packet packet) throws UnauthorizedException {
if (conn != null && !conn.isClosed()) { if (!conn.isClosed()) {
conn.deliver(packet); conn.deliver(packet);
} }
} }
......
...@@ -75,7 +75,7 @@ public abstract class LocalSession implements Session { ...@@ -75,7 +75,7 @@ public abstract class LocalSession implements Session {
/** /**
* The connection that this session represents. * The connection that this session represents.
*/ */
protected Connection conn; protected final Connection conn;
protected SessionManager sessionManager; protected SessionManager sessionManager;
...@@ -101,6 +101,9 @@ public abstract class LocalSession implements Session { ...@@ -101,6 +101,9 @@ public abstract class LocalSession implements Session {
* @param streamID unique identifier for this session. * @param streamID unique identifier for this session.
*/ */
public LocalSession(String serverName, Connection connection, StreamID streamID) { public LocalSession(String serverName, Connection connection, StreamID streamID) {
if (connection == null) {
throw new IllegalArgumentException("connection must not be null");
}
conn = connection; conn = connection;
this.streamID = streamID; this.streamID = streamID;
this.serverName = serverName; this.serverName = serverName;
...@@ -328,10 +331,8 @@ public abstract class LocalSession implements Session { ...@@ -328,10 +331,8 @@ public abstract class LocalSession implements Session {
abstract void deliver(Packet packet) throws UnauthorizedException; abstract void deliver(Packet packet) throws UnauthorizedException;
public void deliverRawText(String text) { public void deliverRawText(String text) {
if (conn != null) {
conn.deliverRawText(text); conn.deliverRawText(text);
} }
}
/** /**
* Returns a text with the available stream features. Each subclass may return different * Returns a text with the available stream features. Each subclass may return different
...@@ -342,10 +343,8 @@ public abstract class LocalSession implements Session { ...@@ -342,10 +343,8 @@ public abstract class LocalSession implements Session {
public abstract String getAvailableStreamFeatures(); public abstract String getAvailableStreamFeatures();
public void close() { public void close() {
if (conn != null) {
conn.close(); conn.close();
} }
}
public boolean validate() { public boolean validate() {
return conn.validate(); return conn.validate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment