alibaba/canal · error · NullPointerException
null zooKeeperLogPositionManager
Error message
null zooKeeperLogPositionManager
What it means
PeriodMixedLogPositionManager requires a ZooKeeperLogPositionManager as its durable delegate. A null value throws NullPointerException at construction because there is no durable backend to flush to.
Source
Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/index/PeriodMixedLogPositionManager.java:43
private MemoryLogPositionManager memoryLogPositionManager;
private ZooKeeperLogPositionManager zooKeeperLogPositionManager;
private ScheduledExecutorService executorService;
private long period;
private Set<String> persistTasks;
@SuppressWarnings("serial")
private final LogPosition nullPosition = new LogPosition() {
};
public PeriodMixedLogPositionManager(MemoryLogPositionManager memoryLogPositionManager,
ZooKeeperLogPositionManager zooKeeperLogPositionManager, long period){
if (memoryLogPositionManager == null) {
throw new NullPointerException("null memoryLogPositionManager");
}
if (zooKeeperLogPositionManager == null) {
throw new NullPointerException("null zooKeeperLogPositionManager");
}
if (period <= 0) {
throw new IllegalArgumentException("period must be positive, given: " + period);
}
this.memoryLogPositionManager = memoryLogPositionManager;
this.zooKeeperLogPositionManager = zooKeeperLogPositionManager;
this.period = period;
this.persistTasks = Collections.synchronizedSet(new HashSet<>());
this.executorService = Executors.newScheduledThreadPool(1);
}
@Override
public void stop() {
super.stop();
if (zooKeeperLogPositionManager.isStart()) {View on GitHub (pinned to 87be50e876)
Solutions
- Build a non-null ZooKeeperLogPositionManager from a valid zkClient and pass it as the second argument.
- Ensure the underlying ZkClientx is created (canal.zkServers set) so the zk manager is non-null.
- Verify constructor argument order: (memory, zooKeeper, period).
Example fix
// before new PeriodMixedLogPositionManager(memMgr, null, period); // after ZooKeeperLogPositionManager zkMgr = new ZooKeeperLogPositionManager(zk); new PeriodMixedLogPositionManager(memMgr, zkMgr, period);
Defensive patterns
Strategy: validation
Validate before calling
ZooKeeperLogPositionManager zk = Objects.requireNonNull(zkMgr, "zooKeeperLogPositionManager"); new PeriodMixedLogPositionManager(memMgr, zk, period);
Type guard
boolean hasZkManager(ZooKeeperLogPositionManager z) { return z != null; } Prevention
- Build ZooKeeperLogPositionManager from a non-null zkClient first.
- Verify argument order: (memory, zooKeeper, period).
When it happens
Trigger: Constructing PeriodMixedLogPositionManager with zooKeeperLogPositionManager == null. This happens when the ZooKeeperLogPositionManager was not built (e.g. zkClient was null upstream) or was injected incorrectly.
Common situations: The zkClient is unset so ZooKeeperLogPositionManager was never constructed; Spring property binding wired the wrong bean; a refactor changed the constructor signature.
Related errors
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/3db1df7a52b62722.
Report an issue: GitHub.