{"record":{"id":"732a84077991006a","repo":"alibaba/canal","slug":"null-memorylogpositionmanager","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/FileMixedLogPositionManager.java","lineNumber":64,"sourceCode":"\n    @SuppressWarnings(\"serial\")\n    private final LogPosition        nullPosition = new LogPosition() {\n                                                  };\n\n    private MemoryLogPositionManager memoryLogPositionManager;\n\n    private long                     period;\n    private Set<String>              persistTasks;\n\n    public FileMixedLogPositionManager(File dataDir, long period, MemoryLogPositionManager memoryLogPositionManager){\n        if (dataDir == null) {\n            throw new NullPointerException(\"null dataDir\");\n        }\n        if (period <= 0) {\n            throw new IllegalArgumentException(\"period must be positive, given: \" + period);\n        }\n        if (memoryLogPositionManager == null) {\n            throw new NullPointerException(\"null memoryLogPositionManager\");\n        }\n        this.dataDir = dataDir;\n        this.period = period;\n        this.memoryLogPositionManager = memoryLogPositionManager;\n\n        this.dataFileCaches = MigrateMap.makeComputingMap(this::getDataFile);\n\n        this.executorService = Executors.newScheduledThreadPool(1);\n        this.persistTasks = Collections.synchronizedSet(new HashSet<>());\n    }\n\n    @Override\n    public void start() {\n        super.start();\n\n        if (!dataDir.exists()) {\n            try {\n                FileUtils.forceMkdir(dataDir);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/index/FileMixedLogPositionManager.java#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"Spring wiring omitted the memoryLogPositionManager property; the manager was set to null by a custom factory; a refactor passed the wrong argument order.","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."],"exampleFix":"// before\nnew FileMixedLogPositionManager(dir, period, null);\n\n// after\nMemoryLogPositionManager mem = new MemoryLogPositionManager();\nnew FileMixedLogPositionManager(dir, period, mem);","handlingStrategy":"validation","validationCode":"MemoryLogPositionManager mem = Objects.requireNonNull(memoryMgr, \"memoryLogPositionManager\");\nnew FileMixedLogPositionManager(dir, period, mem);","typeGuard":"boolean hasMemoryManager(MemoryLogPositionManager m) { return m != null; }","tryCatchPattern":null,"preventionTips":["Use constructor injection for the memory delegate.","Create a fresh MemoryLogPositionManager per FileMixed manager; do not share or reuse."],"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"}