mojira.dev
MC-249702

Server crash when attempting to start a server with malformatted banned-ips.json

The bug

Attempting to start a server with square brackets missing in banned-ips.json causes a crash.

Stack trace

1.18.2\: [^crash-2022-03-30_19.35.41-server.txt]

Description: Exception in server tick loop

java.lang.NullPointerException: Cannot invoke "com.google.gson.JsonArray.iterator()" because "$$1" is null
	at ags.f(SourceFile:121)
	at acw.y(SourceFile:76)
	at acw.<init>(SourceFile:25)
	at acx.e(SourceFile:172)
	at net.minecraft.server.MinecraftServer.w(SourceFile:670)
	at net.minecraft.server.MinecraftServer.a(SourceFile:273)
	at java.base/java.lang.Thread.run(Thread.java:833)

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 6

pinpointed the issue to the banned-ips.json file, the square brackets were missing (no ips were banned, literally a blank file) threw me off a little, especially given the error message, either way, issue fixed

You should leave this open, it shouldn't crash because the file is empty/malformatted. (Empty should just default to a newly generated file, malformatted, I'd suggest, creating a backup file and emptying the original.)
Might want to check if the same happens with banned players, whitelist and ops files.

Code analysis (1.18.2): when loading ops and whitelist files, Exception is caught and ignored, but when loading bans, only IOException is caught. Since JSON parsing exceptions are not IOException, it will propagate and crash.

DedicatedPlayerManager.java

private void loadUserBanList() {
    try {
      getUserBanList().load();
    } catch (IOException iOException) { // IOException only
      LOGGER.warn("Failed to load user banlist: ", iOException);
    } 
  }
  
  private void loadOpList() {
    try {
      getOpList().load();
    } catch (Exception exception) { // All exceptions
      LOGGER.warn("Failed to load operators list: ", exception);
    } 
  }

Thank you for your report!
We're resolving and linking this ticket forward as a duplicate of MC-251813, as that ticket contains more detailed information and/or has already been triaged by Mojang.

If you would like to add a vote and any extra information to the main ticket it would be appreciated.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

Marked as related as the stack traces are quite different.

justin barrett

(Unassigned)

Confirmed

Platform

Important

Crash, Dedicated Server

banned-ips.json

1.18.2, 1.19.3, 23w05a

1.20.2 Pre-release 2

Retrieved