alibaba/canal · error · NullPointerException
null memoryLogPositionManager
Error message
null memoryLogPositionManager
What it means
FileMixedLogPositionManager composes a MemoryLogPositionManager to hold the hot in-memory copy and a file store for persistence. The memory delegate is mandatory; a null value throws NullPointerException at construction. Without it the read-through cache and staging area do not exist.
Source
Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/index/FileMixedLogPositionManager.java:64
@SuppressWarnings("serial")
private final LogPosition nullPosition = new LogPosition() {
};
private MemoryLogPositionManager memoryLogPositionManager;
private long period;
private Set<String> persistTasks;
public FileMixedLogPositionManager(File dataDir, long period, MemoryLogPositionManager memoryLogPositionManager){
if (dataDir == null) {
throw new NullPointerException("null dataDir");
}
if (period <= 0) {
throw new IllegalArgumentException("period must be positive, given: " + period);
}
if (memoryLogPositionManager == null) {
throw new NullPointerException("null memoryLogPositionManager");
}
this.dataDir = dataDir;
this.period = period;
this.memoryLogPositionManager = memoryLogPositionManager;
this.dataFileCaches = MigrateMap.makeComputingMap(this::getDataFile);
this.executorService = Executors.newScheduledThreadPool(1);
this.persistTasks = Collections.synchronizedSet(new HashSet<>());
}
@Override
public void start() {
super.start();
if (!dataDir.exists()) {
try {
FileUtils.forceMkdir(dataDir);View on GitHub (pinned to 87be50e876)
Solutions
- Ensure a fresh, non-started MemoryLogPositionManager is injected as the third constructor argument.
- Verify Spring/bean config actually defines and links the memoryLogPositionManager.
- Avoid reusing a memory manager instance that another component already owns.
Example fix
// before new FileMixedLogPositionManager(dir, period, null); // after MemoryLogPositionManager mem = new MemoryLogPositionManager(); new FileMixedLogPositionManager(dir, period, mem);
Defensive patterns
Strategy: validation
Validate before calling
MemoryLogPositionManager mem = Objects.requireNonNull(memoryMgr, "memoryLogPositionManager"); new FileMixedLogPositionManager(dir, period, mem);
Type guard
boolean hasMemoryManager(MemoryLogPositionManager m) { return m != null; } Prevention
- Use constructor injection for the memory delegate.
- Create a fresh MemoryLogPositionManager per FileMixed manager; do not share or reuse.
When it happens
Trigger: Calling the FileMixedLogPositionManager constructor with memoryLogPositionManager == null, e.g. when the memory manager bean was not created or was already started/closed by another component.
Common situations: Spring wiring omitted the memoryLogPositionManager property; the manager was set to null by a custom factory; a refactor passed the wrong argument order.
Related errors
- nul secondary LogPositionManager
- null metaManager
- null memoryLogPositionManager
- null dataDir
- null zkClient
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/732a84077991006a.
Report an issue: GitHub.