From 5701c3644642204ccd2fd4dc0ccee625d72250b6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 26 Jan 2015 19:26:49 +0100 Subject: [PATCH] * Fixed possible null pointer exception. --- .../src/main/java/mage/server/game/GameSessionPlayer.java | 4 ++-- Mage/src/mage/target/TargetPlayer.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java b/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java index 8a2bd7d234..3f3e4f2467 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSessionPlayer.java @@ -280,9 +280,9 @@ public class GameSessionPlayer extends GameSessionWatcher { 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())); + logger.debug("- Cause: " + (ex.getCause().getMessage() == null ? "null":ex.getCause().getMessage()), ex); } else { - logger.debug("- ex: " + ex.toString()); + logger.debug("- ex: " + ex.toString(), ex); } }else { logger.fatal("Game session game quit exception - null gameId:" + game.getId() +" playerId: " + playerId); diff --git a/Mage/src/mage/target/TargetPlayer.java b/Mage/src/mage/target/TargetPlayer.java index c65f8edd2e..a190d517ec 100644 --- a/Mage/src/mage/target/TargetPlayer.java +++ b/Mage/src/mage/target/TargetPlayer.java @@ -196,7 +196,12 @@ public class TargetPlayer extends TargetImpl { public String getTargetedName(Game game) { StringBuilder sb = new StringBuilder(); for (UUID targetId: getTargets()) { - sb.append(game.getPlayer(targetId).getName()).append(" "); + Player player = game.getPlayer(targetId); + if (player != null) { + sb.append(player.getName()).append(" "); + } else { + sb.append("[target missing]"); + } } return sb.toString(); }