server logging for nulls

This commit is contained in:
drmDev 2016-04-14 10:49:08 -04:00
parent bee12d709c
commit ad0dde4501
2 changed files with 18 additions and 2 deletions

View file

@ -40,6 +40,7 @@ import mage.abilities.mana.ManaAbility;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.util.ThreadLocalStringBuilder; import mage.util.ThreadLocalStringBuilder;
import org.apache.log4j.Logger;
/** /**
* *
@ -48,6 +49,8 @@ import mage.util.ThreadLocalStringBuilder;
*/ */
public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Abilities<T> { public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Abilities<T> {
private static final Logger logger = Logger.getLogger(AbilitiesImpl.class);
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200); private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200);
public AbilitiesImpl() { public AbilitiesImpl() {
@ -102,8 +105,12 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
rules.add(sbRule.toString()); rules.add(sbRule.toString());
} }
String rule = ability.getRule(); String rule = ability.getRule();
if (rule != null && rule.length() > 0) { if (rule != null) {
rules.add(Character.toUpperCase(rule.charAt(0)) + rule.substring(1)); if (rule.length() > 0) {
rules.add(Character.toUpperCase(rule.charAt(0)) + rule.substring(1));
}
} else { // logging so we can still can be made aware of rule problems a card has
logger.fatal("Error in rule text generation of " + source + ": Create a bug report or fix the source code");
} }
} }
} }

View file

@ -51,6 +51,7 @@ import mage.target.Target;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil; import mage.util.CardUtil;
import org.apache.log4j.Logger;
/** /**
* *
@ -58,6 +59,8 @@ import mage.util.CardUtil;
*/ */
public class AwakenAbility extends SpellAbility { public class AwakenAbility extends SpellAbility {
private static final Logger logger = Logger.getLogger(AwakenAbility.class);
static private String filterMessage = "a land you control to awake"; static private String filterMessage = "a land you control to awake";
private String rule; private String rule;
@ -135,6 +138,12 @@ public class AwakenAbility extends SpellAbility {
effect.setTargetPointer(fixedTarget); effect.setTargetPointer(fixedTarget);
return effect.apply(game, source); return effect.apply(game, source);
} }
} else { // source should never be null, but we are seeing a lot of NPEs from this section
if (source == null) {
logger.fatal("Source was null in AwakenAbility: Create a bug report or fix the source code");
} else if (source.getTargets() == null) {
logger.fatal("getTargets was null in AwakenAbility for " + source + " : Create a bug report or fix the source code");
}
} }
return true; return true;
} }