Skip to content

Commit

Permalink
Fix NPE when manifests don't contain JVM arguments
Browse files Browse the repository at this point in the history
Jackson upgrade exposed/introduced a bug where the JVM half of Minecraft
arguments could end up missing in some cases. Not exactly sure if the
field was null on the serializing side or just an empty array, but we
just fix it by always initializing the fields.
  • Loading branch information
hedgehog1029 committed Apr 27, 2022
1 parent 0a5abee commit 2fe96e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.skcraft.launcher.model.minecraft.MinecraftArguments;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
Expand All @@ -29,7 +28,6 @@ public class VersionInfo {

public void setMinecraftArguments(String argumentString) {
MinecraftArguments minecraftArguments = new MinecraftArguments();
minecraftArguments.setGameArguments(new ArrayList<GameArgument>());

for (String arg : Splitter.on(' ').split(argumentString)) {
minecraftArguments.getGameArguments().add(new GameArgument(arg));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.skcraft.launcher.model.minecraft.mapper.MinecraftArgumentsSerializer;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
Expand All @@ -18,12 +19,12 @@ public class MinecraftArguments {
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
@JsonSerialize(contentUsing = MinecraftArgumentsSerializer.class)
@JsonDeserialize(contentUsing = MinecraftArgumentsDeserializer.class)
private List<GameArgument> gameArguments;
private List<GameArgument> gameArguments = new ArrayList<>();

@JsonProperty("jvm")
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
@JsonSerialize(contentUsing = MinecraftArgumentsSerializer.class)
@JsonDeserialize(contentUsing = MinecraftArgumentsDeserializer.class)
private List<GameArgument> jvmArguments;
private List<GameArgument> jvmArguments = new ArrayList<>();
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import com.skcraft.launcher.model.loader.SidedData;
import lombok.Data;

import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down Expand Up @@ -50,8 +53,6 @@ public Library findLibrary(String name) {

public void setMinecraftArguments(String minecraftArguments) {
MinecraftArguments result = new MinecraftArguments();
result.setGameArguments(new ArrayList<GameArgument>());
result.setJvmArguments(new ArrayList<GameArgument>());

for (String arg : Splitter.on(' ').split(minecraftArguments)) {
result.getGameArguments().add(new GameArgument(arg));
Expand Down

0 comments on commit 2fe96e4

Please sign in to comment.