Log warning message when failing to uninject from velocity initializer

It shouldn't break anything, but it's a massive memory leak

Follow-up to #1379
This commit is contained in:
booky committed 2026-01-10 19:15:11 +01:00
1 parent ae928dbee1
commit 90a196d3bc
2 files changed
+11 -4

No files matched your search

@@ -82,9 +82,11 @@ public class VelocityPipelineInjector implements ChannelInjector {
if (wrapper instanceof VelocityChannelInitializer) {
try {
SET_SERVER_INTIIALIZER.invoke(initializerHolder, ((VelocityChannelInitializer) wrapper).getWrappedInitializer());
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException | InvocationTargetException exception) {
throw new RuntimeException("Failed to uninject from frontend pipeline", exception);
}
} else {
throw new IllegalStateException("Failed to uninject from frontend pipeline: can't unwrap foreign channel initializer");
}
}
@@ -234,8 +234,13 @@ public class VelocityPacketEventsBuilder {
@Override
public void terminate() {
if (initialized) {
// Uninject the injector
injector.uninject();
// try to uninject the injector
try {
this.injector.uninject();
} catch (Exception exception) {
this.logManager.warn("Failed to uninject from initializer");
exception.printStackTrace();
}
// Remove handlers for players
for (User user : this.protocolManager.getUsers()) {
Channel channel = (Channel) user.getChannel();