From 7b4acbe38611f7ed8415b62c663da3be230eae73 Mon Sep 17 00:00:00 2001 From: Ingmar Goudt Date: Thu, 27 Sep 2018 22:16:32 +0200 Subject: [PATCH] clean up some null checks --- .../src/main/java/mage/server/TableController.java | 2 +- .../main/java/mage/server/game/GameController.java | 4 ++-- .../src/main/java/mage/server/game/GameWorker.java | 11 +++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 58a0b695b8..1f4d9808cd 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -942,7 +942,7 @@ public class TableController { if (!(table.getState() == TableState.WAITING || table.getState() == TableState.STARTING || table.getState() == TableState.READY_TO_START)) { if (match == null) { logger.warn("- Match table with no match:"); - logger.warn("-- matchId:" + match.getId() + " [" + match.getName() + ']'); + logger.warn("-- matchId:" + match.getId() + " , table : " + table.getId()); // return false; } else if (match.isDoneSideboarding() && match.getGame() == null) { // no sideboarding and not active game -> match seems to hang (maybe the Draw bug) diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index a9593816c7..b3a1f6d7d1 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -266,13 +266,13 @@ public class GameController implements GameCallback { public void join(UUID userId) { UUID playerId = userPlayerMap.get(userId); - Optional user = UserManager.instance.getUser(userId); - if (userId == null || playerId == null) { + if (playerId == null) { logger.fatal("Join game failed!"); logger.fatal("- gameId: " + game.getId()); logger.fatal("- userId: " + userId); return; } + Optional user = UserManager.instance.getUser(userId); if (!user.isPresent()) { logger.fatal("User not found : " + userId); return; diff --git a/Mage.Server/src/main/java/mage/server/game/GameWorker.java b/Mage.Server/src/main/java/mage/server/game/GameWorker.java index de273e5cc1..e52f9d7cc8 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameWorker.java +++ b/Mage.Server/src/main/java/mage/server/game/GameWorker.java @@ -3,14 +3,14 @@ package mage.server.game; import java.util.UUID; import java.util.concurrent.Callable; + import mage.MageException; import mage.game.Game; import org.apache.log4j.Logger; /** - * - * @author BetaSteward_at_googlemail.com * @param + * @author BetaSteward_at_googlemail.com */ public class GameWorker implements Callable { @@ -40,12 +40,7 @@ public class GameWorker implements Callable { } catch (Exception e) { LOGGER.fatal("GameWorker general exception [" + game.getId() + "] " + e.getMessage(), e); if (e instanceof NullPointerException) { - if (e.getStackTrace() == null) { - LOGGER.info("Stack trace is null"); - } else { - LOGGER.info("Null-Pointer-Exception: Stack trace"); - LOGGER.info(e.getStackTrace()); - } + LOGGER.info(e.getStackTrace()); } } catch (Error err) { LOGGER.fatal("GameWorker general error [" + game.getId() + "] " + err, err);