alibaba/canal · error · NullPointerException
null memoryLogPositionManager
Error message
null memoryLogPositionManager
What it means
PeriodMixedLogPositionManager composes a MemoryLogPositionManager and a ZooKeeperLogPositionManager and periodically flushes the memory copy to ZooKeeper. The memory delegate is mandatory; a null value throws NullPointerException at construction.
Source
Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/index/PeriodMixedLogPositionManager.java:39
public class PeriodMixedLogPositionManager extends AbstractLogPositionManager {
private static final Logger logger = LoggerFactory.getLogger(PeriodMixedLogPositionManager.class);
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);
}
@OverrideView on GitHub (pinned to 87be50e876)
Solutions
- Pass a fresh MemoryLogPositionManager as the first argument.
- Double-check constructor argument order: (memory, zooKeeper, period).
- Verify the memory manager bean is actually instantiated in the context.
Example fix
// before new PeriodMixedLogPositionManager(null, zkMgr, period); // after new PeriodMixedLogPositionManager(new MemoryLogPositionManager(), zkMgr, period);
Defensive patterns
Strategy: validation
Validate before calling
MemoryLogPositionManager mem = Objects.requireNonNull(memoryMgr, "memoryLogPositionManager"); new PeriodMixedLogPositionManager(mem, zkMgr, period);
Type guard
boolean hasMemoryManager(MemoryLogPositionManager m) { return m != null; } Prevention
- Use named/constructor injection to keep memory and zk delegates distinct.
- Double-check the (memory, zooKeeper, period) argument order.
When it happens
Trigger: Constructing PeriodMixedLogPositionManager with memoryLogPositionManager == null. Happens when the in-memory manager bean was not created or was injected as null by the factory.
Common situations: Spring wiring omits the memoryLogPositionManager property; a custom builder returns null; argument order mistake (passing the zk manager into the memory slot).
Related errors
- nul secondary LogPositionManager
- null memoryLogPositionManager
- null metaManager
- null dataDir
- null zkClient
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/d05de464ede2a5d8.
Report an issue: GitHub.