[Functions] Prevent NPE while stopping a non started Pulsar LogAppender
@@ -108,7 +108,7 @@ public class LogAppender implements Appender {
.property("function", fqn)
.create();
} catch (Exception e) {
- throw new RuntimeException("Error starting LogTopic Producer", e);
+ throw new RuntimeException("Error starting LogTopic Producer for function " + fqn, e);
}
this.state = State.STARTED;
}
@@ -116,8 +116,10 @@ public class LogAppender implements Appender {
@Override
public void stop() {
this.state = State.STOPPING;
+ if (producer != null) {
producer.closeAsync();
producer = null;
+ }
this.state = State.STOPPED;
}
