From 8027656386cc3023d428ea0382358244027396df Mon Sep 17 00:00:00 2001 From: zaaarf Date: Fri, 30 Aug 2024 12:20:46 +0200 Subject: [PATCH] fix: avoid nullptr in generated code --- src/main/java/ftbsc/geb/processor/GEBProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ftbsc/geb/processor/GEBProcessor.java b/src/main/java/ftbsc/geb/processor/GEBProcessor.java index 60ba4ff..57655cd 100644 --- a/src/main/java/ftbsc/geb/processor/GEBProcessor.java +++ b/src/main/java/ftbsc/geb/processor/GEBProcessor.java @@ -215,9 +215,9 @@ public class GEBProcessor extends AbstractProcessor { for(ListenerContainer listener : ordered) { String varName = String.format("listener%d", done.get(listener.parent)); callListenersBuilder - .addStatement("for($T l : $L) {", this.listenerInterface, varName) + .addStatement("if($L != null) { for($T l : $L) {", varName, this.listenerInterface, varName) .addStatement( - "if(l != null) (($T) l).$L(($T) $N); }", + "if(l != null) (($T) l).$L(($T) $N); } }", listener.parent, listener.method.getSimpleName().toString(), event,