View Full Version : [Bug Report] If an exception is thrown at userExit, the user keeps logged.
butaca
04-22-2012, 12:13 AM
In a room plugin, if an exception is thrown in the userExit method, the user remains logged in (then the user can't log in again).
I know it an odd scenario but I think is ES responsibility to keep its consistency despite the eventual extensions bugs.
ElectroServer 5.3.2
Hope it helps! :)
tcarr
04-22-2012, 12:37 AM
In your LoginEventHandler, add these lines after you have verified that you want to allow this user to log in, and it will fix the "user can't log in again" problem:
if (getApi().isUserLoggedIn(userName)) {
// we assume that this other user is a ghost.
// Evict doesn't really send the evicted user any message.
getApi().evictUserFromServer(password, new EsObject());
}
It is impossible for the server to cleanly recover from every possible exception that a custom extension can throw. If you have code that might throw such an exception, have userExit use a scheduled execution and then execute the code from that, where it is a separate thread.
butaca
04-26-2012, 05:42 PM
"It is impossible for the server to cleanly recover from every possible exception that a custom extension can throw"
From my humble opinion, you can with a different server design. It is a design issue.
Anyway, thanks for the useful code hint.
tcarr
04-26-2012, 05:51 PM
Another option is for you to put your questionable code into a try block so that it catches exceptions.
tcarr
04-26-2012, 06:43 PM
Our development team is interested in your bug. Do you have server logs from when this happened? We can't figure out how your user wouldn't be able to log back in again, unless he had a dirty disconnect and then was trying to log in before the idle timeout was reached.
butaca
04-26-2012, 07:34 PM
1) The try catch block, was the solution I used as a workaround just in case. However, it is an exceptional situation, my code shouldn't throw an exception. When it did, it was due to a programming mistake made by me.
2) It is really easy to reproduce. Just throw a RuntimeException at userExit in a server plugin:
@Override
public void userExit(String userName) {
super.userExit(userName);
throw new RuntimeException();
}
I'm attaching the log (by the way, It was a really complicated process... :\ )
Good luck!
tcarr
04-26-2012, 07:47 PM
Thanks for the log!
Powered by vBulletin® Version 4.1.6 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.