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 {
public HttpSession(PacketDeliverer backupDeliverer, String serverName, InetAddress address,
StreamID streamID, long rid, HttpConnection connection) {
super(serverName, null, streamID);
conn = new HttpVirtualConnection(address);
super(serverName, new HttpVirtualConnection(address), streamID);
this.isClosed = false;
this.lastActivity = System.currentTimeMillis();
this.lastRequestID = rid;
......
......@@ -854,14 +854,7 @@ public class LocalClientSession extends LocalSession implements ClientSession {
@Override
public void deliver(Packet packet) throws UnauthorizedException {
if (conn != null) {
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);
}
conn.deliver(packet);
}
@Override
......
......@@ -302,7 +302,7 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
@Override
void deliver(Packet packet) throws UnauthorizedException {
if (conn != null && !conn.isClosed()) {
if (!conn.isClosed()) {
conn.deliver(packet);
}
}
......
......@@ -611,7 +611,7 @@ public class LocalOutgoingServerSession extends LocalServerSession implements Ou
@Override
void deliver(Packet packet) throws UnauthorizedException {
if (conn != null && !conn.isClosed()) {
if (!conn.isClosed()) {
conn.deliver(packet);
}
}
......
......@@ -75,7 +75,7 @@ public abstract class LocalSession implements Session {
/**
* The connection that this session represents.
*/
protected Connection conn;
protected final Connection conn;
protected SessionManager sessionManager;
......@@ -101,6 +101,9 @@ public abstract class LocalSession implements Session {
* @param streamID unique identifier for this session.
*/
public LocalSession(String serverName, Connection connection, StreamID streamID) {
if (connection == null) {
throw new IllegalArgumentException("connection must not be null");
}
conn = connection;
this.streamID = streamID;
this.serverName = serverName;
......@@ -328,9 +331,7 @@ public abstract class LocalSession implements Session {
abstract void deliver(Packet packet) throws UnauthorizedException;
public void deliverRawText(String text) {
if (conn != null) {
conn.deliverRawText(text);
}
conn.deliverRawText(text);
}
/**
......@@ -342,9 +343,7 @@ public abstract class LocalSession implements Session {
public abstract String getAvailableStreamFeatures();
public void close() {
if (conn != null) {
conn.close();
}
conn.close();
}
public boolean 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