Skip to content

Commit

Permalink
Fix NPE with returnFire field. (#11729)
Browse files Browse the repository at this point in the history
The field was marked as transient in two classes, meaning it would not be serialized and was null on deserialization, but the code did not handle it properly. Since the leaf code using it was marked with  `@RemoveOnNextMajorRelease` and could handle null, simply remove the non-null tag and propagate the deprecation tag.

Fixes #11097.
  • Loading branch information
asvitkine authored Jul 5, 2023
1 parent c1792b7 commit 7db4403
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import lombok.Builder;
import org.triplea.java.RemoveOnNextMajorRelease;

/** Build the steps for the fire round (roll dice, select casualties, and mark casualties) */
@Builder
Expand All @@ -24,7 +25,10 @@ public class FireRoundStepsFactory {
@Nonnull final BattleActions battleActions;
@Nonnull final Function<BattleState, Collection<FiringGroup>> firingGroupSplitter;
@Nonnull final BattleState.Side side;
@Nonnull final MustFightBattle.ReturnFire returnFire;

@RemoveOnNextMajorRelease("This is ReturnFire.ALL or null for everything except old saves")
final MustFightBattle.ReturnFire returnFire;

@Nonnull final BiFunction<IDelegateBridge, RollDiceStep, DiceRoll> diceRoller;
@Nonnull final BiFunction<IDelegateBridge, SelectCasualties, CasualtyDetails> casualtySelector;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MarkCasualties implements BattleStep {

private final FireRoundState fireRoundState;

@RemoveOnNextMajorRelease("This is ReturnFire.ALL for everything except old saves")
@RemoveOnNextMajorRelease("This is ReturnFire.ALL or null for everything except old saves")
private final MustFightBattle.ReturnFire returnFire;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.triplea.java.RemoveOnNextMajorRelease;

/** Generates fire steps for the first strike battle phase for the defensive player */
public class DefensiveFirstStrike implements BattleStep {
Expand All @@ -39,6 +40,7 @@ private enum State {

protected final State state;

@RemoveOnNextMajorRelease("This is ReturnFire.ALL or null for everything except old saves")
protected transient ReturnFire returnFire = ReturnFire.ALL;

public DefensiveFirstStrike(final BattleState battleState, final BattleActions battleActions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.triplea.java.RemoveOnNextMajorRelease;

/** Generates fire steps for the first strike battle phase for the offensive player */
public class OffensiveFirstStrike implements BattleStep {
Expand All @@ -39,6 +40,7 @@ private enum State {

protected final State state;

@RemoveOnNextMajorRelease("This is ReturnFire.ALL or null for everything except old saves")
protected transient ReturnFire returnFire = ReturnFire.ALL;

public OffensiveFirstStrike(final BattleState battleState, final BattleActions battleActions) {
Expand Down

0 comments on commit 7db4403

Please sign in to comment.