{"record":{"id":"d05de464ede2a5d8","repo":"alibaba/canal","slug":"null-memorylogpositionmanager-d05de4","errorCode":null,"errorMessage":"null memoryLogPositionManager","messagePattern":"null memoryLogPositionManager","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/index/PeriodMixedLogPositionManager.java","lineNumber":39,"sourceCode":"public class PeriodMixedLogPositionManager extends AbstractLogPositionManager {\n\n    private static final Logger         logger       = LoggerFactory.getLogger(PeriodMixedLogPositionManager.class);\n\n    private MemoryLogPositionManager    memoryLogPositionManager;\n    private ZooKeeperLogPositionManager zooKeeperLogPositionManager;\n    private ScheduledExecutorService    executorService;\n\n    private long                        period;\n    private Set<String>                 persistTasks;\n\n    @SuppressWarnings(\"serial\")\n    private final LogPosition           nullPosition = new LogPosition() {\n                                                     };\n\n    public PeriodMixedLogPositionManager(MemoryLogPositionManager memoryLogPositionManager,\n                                         ZooKeeperLogPositionManager zooKeeperLogPositionManager, long period){\n        if (memoryLogPositionManager == null) {\n            throw new NullPointerException(\"null memoryLogPositionManager\");\n        }\n\n        if (zooKeeperLogPositionManager == null) {\n            throw new NullPointerException(\"null zooKeeperLogPositionManager\");\n        }\n\n        if (period <= 0) {\n            throw new IllegalArgumentException(\"period must be positive, given: \" + period);\n        }\n\n        this.memoryLogPositionManager = memoryLogPositionManager;\n        this.zooKeeperLogPositionManager = zooKeeperLogPositionManager;\n        this.period = period;\n        this.persistTasks = Collections.synchronizedSet(new HashSet<>());\n        this.executorService = Executors.newScheduledThreadPool(1);\n    }\n\n    @Override","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/index/PeriodMixedLogPositionManager.java#L21-L57","documentation":"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.","triggerScenarios":"Constructing PeriodMixedLogPositionManager with memoryLogPositionManager == null. Happens when the in-memory manager bean was not created or was injected as null by the factory.","commonSituations":"Spring wiring omits the memoryLogPositionManager property; a custom builder returns null; argument order mistake (passing the zk manager into the memory slot).","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."],"exampleFix":"// before\nnew PeriodMixedLogPositionManager(null, zkMgr, period);\n\n// after\nnew PeriodMixedLogPositionManager(new MemoryLogPositionManager(), zkMgr, period);","handlingStrategy":"validation","validationCode":"MemoryLogPositionManager mem = Objects.requireNonNull(memoryMgr, \"memoryLogPositionManager\");\nnew PeriodMixedLogPositionManager(mem, zkMgr, period);","typeGuard":"boolean hasMemoryManager(MemoryLogPositionManager m) { return m != null; }","tryCatchPattern":null,"preventionTips":["Use named/constructor injection to keep memory and zk delegates distinct.","Double-check the (memory, zooKeeper, period) argument order."],"tags":["canal","log-position-manager","null-check","configuration","constructor"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}