Turnabout on Character stats concurrency + Null remote IP patch

Cleared the concurrency conflicts that started occuring after the abstract character's listener code was set to run on new thread, potentally leading to several onStatChange mishaps.
Added a check for remoteHost being possibly null when opening a new session with the client.
This commit is contained in:
ronancpl
2019-04-23 11:14:40 -03:00
parent 1376c295e1
commit e18061ffaf
7 changed files with 48 additions and 42 deletions

View File

@@ -106,7 +106,18 @@ public class MapleServerHandler extends IoHandlerAdapter {
@Override
public void sessionOpened(IoSession session) {
session.setAttribute(MapleClient.CLIENT_REMOTE_ADDRESS, ((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
String remoteHost;
try {
remoteHost = ((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress();
if (remoteHost == null) {
remoteHost = "null";
}
} catch (NullPointerException npe) { // thanks Agassy, Alchemist for pointing out possibility of remoteHost = null.
remoteHost = "null";
}
session.setAttribute(MapleClient.CLIENT_REMOTE_ADDRESS, remoteHost);
if (!Server.getInstance().isOnline()) {
MapleSessionCoordinator.getInstance().closeSession(session, true);