Commit fdb96256 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed NPE when a client used uppercase letters in the username. JM-124


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@912 b35dd754-fafc-0310-a699-88a17e54d16e
parent 93d8fd68
...@@ -353,8 +353,7 @@ public class SessionManager extends BasicModule implements ConnectionCloseListen ...@@ -353,8 +353,7 @@ public class SessionManager extends BasicModule implements ConnectionCloseListen
// A non-anonymous session is now available // A non-anonymous session is now available
Session defaultSession = null; Session defaultSession = null;
try { try {
String username = session.getUsername().toLowerCase(); defaultSession = sessions.get(session.getUsername()).getDefaultSession(true);
defaultSession = sessions.get(username).getDefaultSession(true);
JID node = new JID(defaultSession.getAddress().getNode(), JID node = new JID(defaultSession.getAddress().getNode(),
defaultSession.getAddress().getDomain(), null); defaultSession.getAddress().getDomain(), null);
// Add route to default session (used when no resource is specified) // Add route to default session (used when no resource is specified)
...@@ -384,8 +383,11 @@ public class SessionManager extends BasicModule implements ConnectionCloseListen ...@@ -384,8 +383,11 @@ public class SessionManager extends BasicModule implements ConnectionCloseListen
// Remove route to the removed session (anonymous or not) // Remove route to the removed session (anonymous or not)
routingTable.removeRoute(session.getAddress()); routingTable.removeRoute(session.getAddress());
try { try {
String username = session.getUsername().toLowerCase(); if (session.getUsername() == null) {
SessionMap sessionMap = sessions.get(username); // Do nothing since this is an anonymous session
return;
}
SessionMap sessionMap = sessions.get(session.getUsername());
// If sessionMap is null, which is an irregular case, try to clean up the routes to // If sessionMap is null, which is an irregular case, try to clean up the routes to
// the user from the routing table // the user from the routing table
if (sessionMap == null) { if (sessionMap == null) {
......
...@@ -96,7 +96,7 @@ public class SessionImpl implements Session { ...@@ -96,7 +96,7 @@ public class SessionImpl implements Session {
if (authToken == null) { if (authToken == null) {
throw new UserNotFoundException(); throw new UserNotFoundException();
} }
return authToken.getUsername(); return address.getNode();
} }
public String getServerName() { public String getServerName() {
......
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