Release runtime statics

- Null Iris.instance, the console sender, the Multiverse link, the compat set and the chunk tickets at the end of teardownRuntime
- Bind the host bridge suppliers to the constructing plugin instead of reading the instance static on every call
- State that Iris is disabled when service, getTemp or getSender is reached after teardown instead of raising a bare NullPointerException
- Add IrisRuntimeStatics so a disable drops the service registry, both capability singletons, the loaded datapack runtime and the localization roots
- Add WorldLifecycleService.reset and WorldRuntimeControlService.reset so the next boot snapshots the server it is running on
- Add ServerConfigurator.resetLoadedDatapackRuntime so an enable revalidates instead of trusting the previous boot's fingerprint
- Clear the localization data folder and plain-text memo on shutdown
- Add BukkitPlatform.releaseHost and call it last in terminal cleanup so the disabled plugin, console sender and log bridge stop being reachable from a static
This commit is contained in:
Brian Neumann-Fopiano
2026-09-08 04:44:32 -04:00
parent f83cf71b11
commit 6c6dba0232
10 changed files with 197 additions and 13 deletions
@@ -39,6 +39,7 @@ import art.arcane.iris.core.SettingsHotloadWatch;
import art.arcane.iris.core.ServerConfigurator;
import art.arcane.iris.core.datapack.DatapackIngestService;
import art.arcane.iris.core.datapack.DatapackIngestService.StartupValidationOutcome;
import art.arcane.iris.core.lifecycle.IrisRuntimeStatics;
import art.arcane.iris.core.lifecycle.ManagedWorldLoader;
import art.arcane.iris.core.lifecycle.MissingWorldStorageLog;
import art.arcane.iris.core.lifecycle.PaperLibBootstrap;
@@ -216,16 +217,23 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
private volatile ServerShutdownBoundary serverShutdownBoundary;
public static VolmitSender getSender() {
if (sender == null) {
sender = new VolmitSender(Bukkit.getConsoleSender());
sender.setTag(instance.getTag());
VolmitSender current = sender;
if (current == null) {
Iris plugin = instance;
current = new VolmitSender(Bukkit.getConsoleSender());
current.setTag(plugin == null ? IrisSafeguard.mode().tag("") : plugin.getTag());
sender = current;
}
return sender;
return current;
}
@SuppressWarnings("unchecked")
public static <T> T service(Class<T> c) {
return (T) instance.services.get(c);
Iris plugin = instance;
if (plugin == null || plugin.services == null) {
throw new IllegalStateException("Iris is disabled; " + c.getSimpleName() + " is unavailable");
}
return (T) plugin.services.get(c);
}
public static void callEvent(Event e) {
@@ -264,7 +272,11 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
}
public static File getTemp() {
return instance.getDataFolder("cache", "temp");
Iris plugin = instance;
if (plugin == null) {
throw new IllegalStateException("Iris is disabled; the temp folder is unavailable");
}
return plugin.getDataFolder("cache", "temp");
}
public static void msg(String string) {
@@ -543,11 +555,11 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
Iris::msg,
Iris::reportError,
(event) -> Iris.callEvent((org.bukkit.event.Event) event),
() -> Iris.instance.getDataFolder(),
(path) -> Iris.instance.getDataFile(path),
() -> Iris.instance.getJarFile(),
() -> Iris.instance.getIrisVersion(),
() -> Iris.instance.getMCVersion()));
this::getDataFolder,
this::getDataFile,
this::getJarFile,
this::getIrisVersion,
this::getMCVersion));
SlimJar.load();
}
@@ -1055,10 +1067,24 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
Iris.reportError("Failed to close Iris I/O workers.", failure);
}
clearQueues();
IrisServices.clear();
IrisRuntimeStatics.reset();
releaseStatics();
}
}
/**
* A disabled plugin must not stay reachable through a static. Everything that reads these either runs
* while Iris is enabled or already handles their absence; the platform binding outlives them because
* core still logs through it until finishTerminalCleanup unbinds it.
*/
private static void releaseStatics() {
linkMultiverseCore = null;
compat = null;
tickets = null;
sender = null;
instance = null;
}
private void quiesceRuntimeForServerShutdown(String reason) {
serverStopTeardownDeferred.set(true);
INMS.get().deferPluginClassLoaderClose();
@@ -1201,6 +1227,7 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
failure.printStackTrace(SHUTDOWN_ERRORS);
}
}
BukkitPlatform.releaseHost();
}
}
@@ -1395,7 +1422,7 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
}
public int getIrisVersion() {
String input = Iris.instance.getDescription().getVersion();
String input = getDescription().getVersion();
int hyphenIndex = input.indexOf('-');
if (hyphenIndex != -1) {
String result = input.substring(0, hyphenIndex);