clean up some null checks

This commit is contained in:
Ingmar Goudt 2018-09-27 22:16:32 +02:00
parent 188a09b8fb
commit 7b4acbe386
3 changed files with 6 additions and 11 deletions

View file

@ -942,7 +942,7 @@ public class TableController {
if (!(table.getState() == TableState.WAITING || table.getState() == TableState.STARTING || table.getState() == TableState.READY_TO_START)) { if (!(table.getState() == TableState.WAITING || table.getState() == TableState.STARTING || table.getState() == TableState.READY_TO_START)) {
if (match == null) { if (match == null) {
logger.warn("- Match table with no match:"); logger.warn("- Match table with no match:");
logger.warn("-- matchId:" + match.getId() + " [" + match.getName() + ']'); logger.warn("-- matchId:" + match.getId() + " , table : " + table.getId());
// return false; // return false;
} else if (match.isDoneSideboarding() && match.getGame() == null) { } else if (match.isDoneSideboarding() && match.getGame() == null) {
// no sideboarding and not active game -> match seems to hang (maybe the Draw bug) // no sideboarding and not active game -> match seems to hang (maybe the Draw bug)

View file

@ -266,13 +266,13 @@ public class GameController implements GameCallback {
public void join(UUID userId) { public void join(UUID userId) {
UUID playerId = userPlayerMap.get(userId); UUID playerId = userPlayerMap.get(userId);
Optional<User> user = UserManager.instance.getUser(userId); if (playerId == null) {
if (userId == null || playerId == null) {
logger.fatal("Join game failed!"); logger.fatal("Join game failed!");
logger.fatal("- gameId: " + game.getId()); logger.fatal("- gameId: " + game.getId());
logger.fatal("- userId: " + userId); logger.fatal("- userId: " + userId);
return; return;
} }
Optional<User> user = UserManager.instance.getUser(userId);
if (!user.isPresent()) { if (!user.isPresent()) {
logger.fatal("User not found : " + userId); logger.fatal("User not found : " + userId);
return; return;

View file

@ -3,14 +3,14 @@ package mage.server.game;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import mage.MageException; import mage.MageException;
import mage.game.Game; import mage.game.Game;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
*
* @author BetaSteward_at_googlemail.com
* @param <T> * @param <T>
* @author BetaSteward_at_googlemail.com
*/ */
public class GameWorker<T> implements Callable { public class GameWorker<T> implements Callable {
@ -40,12 +40,7 @@ public class GameWorker<T> implements Callable {
} catch (Exception e) { } catch (Exception e) {
LOGGER.fatal("GameWorker general exception [" + game.getId() + "] " + e.getMessage(), e); LOGGER.fatal("GameWorker general exception [" + game.getId() + "] " + e.getMessage(), e);
if (e instanceof NullPointerException) { if (e instanceof NullPointerException) {
if (e.getStackTrace() == null) { LOGGER.info(e.getStackTrace());
LOGGER.info("Stack trace is null");
} else {
LOGGER.info("Null-Pointer-Exception: Stack trace");
LOGGER.info(e.getStackTrace());
}
} }
} catch (Error err) { } catch (Error err) {
LOGGER.fatal("GameWorker general error [" + game.getId() + "] " + err, err); LOGGER.fatal("GameWorker general error [" + game.getId() + "] " + err, err);