{"record":{"id":"87b00a884ae5c2d5","repo":"alibaba/canal","slug":"nul-primary-logpositionmanager","errorCode":null,"errorMessage":"nul primary LogPositionManager","messagePattern":"nul primary LogPositionManager","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"critical","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/index/FailbackLogPositionManager.java","lineNumber":26,"sourceCode":"\n/**\n * Created by yinxiu on 17/3/18. Email: marklin.hz@gmail.com\n * 实现基于failover查找的机制完成meta的操作\n *\n * <pre>\n * 应用场景：比如针对内存buffer，出现HA切换，先尝试从内存buffer区中找到lastest position，如果不存在才尝试找一下meta里消费的信息\n * </pre>\n */\npublic class FailbackLogPositionManager extends AbstractLogPositionManager {\n\n    private final static Logger           logger = LoggerFactory.getLogger(FailbackLogPositionManager.class);\n\n    private final CanalLogPositionManager primary;\n    private final CanalLogPositionManager secondary;\n\n    public FailbackLogPositionManager(CanalLogPositionManager primary, CanalLogPositionManager secondary){\n        if (primary == null) {\n            throw new NullPointerException(\"nul primary LogPositionManager\");\n        }\n        if (secondary == null) {\n            throw new NullPointerException(\"nul secondary LogPositionManager\");\n        }\n\n        this.primary = primary;\n        this.secondary = secondary;\n    }\n\n    @Override\n    public void start() {\n        super.start();\n\n        if (!primary.isStart()) {\n            primary.start();\n        }\n\n        if (!secondary.isStart()) {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/index/FailbackLogPositionManager.java#L8-L44","documentation":"Thrown as NullPointerException by the FailbackLogPositionManager constructor when the primary CanalLogPositionManager argument is null. This is a fail-fast constructor validation — the FailbackLogPositionManager requires both a primary and secondary manager to function as a failover pair.","triggerScenarios":"Instantiating new FailbackLogPositionManager(null, secondary) — the primary argument is null. This is a wiring/configuration error, not a runtime data issue. It fails immediately at construction time.","commonSituations":"Spring/XML bean configuration missing the primary LogPositionManager bean reference; the primary bean failed to initialize and was null-wired; programmatic construction where the primary manager was not yet created; a refactoring that removed the primary bean definition.","solutions":["Ensure the primary CanalLogPositionManager bean is defined and injected — typically a MemoryLogPositionManager or ZooKeeperLogPositionManager.","Check Spring/canal XML configuration for missing <constructor-arg> ref for the primary manager.","Verify the primary bean is instantiated before the FailbackLogPositionManager bean.","If constructing programmatically, ensure both primary and secondary are non-null before calling the constructor."],"exampleFix":"// before\nnew FailbackLogPositionManager(null, secondaryManager);\n\n// after\nCanalLogPositionManager primary = new MemoryLogPositionManager();\nnew FailbackLogPositionManager(primary, secondaryManager);","handlingStrategy":"validation","validationCode":"// Validate both managers before constructing FailbackLogPositionManager\nif (primary == null) {\n    throw new IllegalArgumentException(\"Primary LogPositionManager must not be null\");\n}\nif (secondary == null) {\n    throw new IllegalArgumentException(\"Secondary LogPositionManager must not be null\");\n}\nFailbackLogPositionManager manager = new FailbackLogPositionManager(primary, secondary);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define both primary and secondary LogPositionManager beans in Spring configuration.","Verify bean wiring with a startup integration test.","Use constructor injection (not field injection) to fail fast on missing dependencies.","Check canal XML configuration files for all required constructor-arg references."],"tags":["position-manager","constructor","null-check","configuration","canal-parse"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}