Big refactoring (server)

I used Intellij IDEA to automatically refactor code to achive 3 goals.
1) get rid of anonymouse classes, and replace the with lamba to get more readeable and clean code (like in TableWaitingDialog).
2) make effectively final  variables actually final to avoid inadvertent changes on it in further releases and keep objects as immutable, as possible.
3)  Get rid of unused imports (most of the changes) in whole project classes.
This commit is contained in:
vraskulin 2017-01-09 19:47:03 +03:00
parent 076840df53
commit 46d369c8ed
31 changed files with 510 additions and 822 deletions

View file

@ -282,34 +282,31 @@ public class GameSessionPlayer extends GameSessionWatcher {
final Player player = game.getPlayer(playerId);
if (player != null && player.isInGame()) {
callExecutor.execute(
new Runnable() {
@Override
public void run() {
try {
if (game.getStartTime() == null) {
// gameController is still waiting to start the game
player.leave();
} else {
// game was already started
player.quit(game);
}
} catch (Exception ex) {
if (ex != null) {
// It seems this can happen if two threads try to end the game at the exact same time (one wins and one ends here)
logger.fatal("Game session game quit exception " + (ex.getMessage() == null ? "null" : ex.getMessage()));
logger.debug("- gameId:" + game.getId() + " playerId: " + playerId);
if (ex.getCause() != null) {
logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null" : ex.getCause().getMessage()), ex);
() -> {
try {
if (game.getStartTime() == null) {
// gameController is still waiting to start the game
player.leave();
} else {
logger.debug("- ex: " + ex.toString(), ex);
// game was already started
player.quit(game);
}
} catch (Exception ex) {
if (ex != null) {
// It seems this can happen if two threads try to end the game at the exact same time (one wins and one ends here)
logger.fatal("Game session game quit exception " + (ex.getMessage() == null ? "null" : ex.getMessage()));
logger.debug("- gameId:" + game.getId() + " playerId: " + playerId);
if (ex.getCause() != null) {
logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null" : ex.getCause().getMessage()), ex);
} else {
logger.debug("- ex: " + ex.toString(), ex);
}
} else {
logger.fatal("Game session game quit exception - null gameId:" + game.getId() + " playerId: " + playerId);
}
} else {
logger.fatal("Game session game quit exception - null gameId:" + game.getId() + " playerId: " + playerId);
}
}
}
}
);
}