---
title: "otter源码分析-(1)debug node源码"
author: "chenchangqun"
date: "2017-02-24T17:14:13Z"
tags: []
categories: ["互联网"]
slug: "otter-1-debug-node"
draft: false
lastmod: "2017-02-24T17:14:13Z"
id: 2358960
url: "https://chenchangqun.iteye.com/blog/2358960"
---

想解决一个源码的疑问，需要debug otter node模块。

开启同步任务后，local node 的 mainstem一直 显示：定位中，数据更改后，同步功能不可用。

![](http://dl2.iteye.com/upload/attachment/0123/3210/5d364d10-18a9-36d1-ad94-bb40df20418c.png)  
 

 

bug信息如下

pid:8 nid:3 exception:canal:test\_cancal\_debug:java.lang.NullPointerException 

at com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.loadBinlogChecksum(MysqlConnection.java:284) 

at com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.dump(MysqlConnection.java:113) 

at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3.run(AbstractEventParser.java:209) 

at java.lang.Thread.run(Thread.java:745) 

这个问题是当前的1.0.23版本的canal有些问题，参考[https://github.com/alibaba/otter/issues/258](https://github.com/alibaba/otter/issues/258)

 

我想了个办法： 关联local的canal源码，然后手工修复canal 的bug。

cannal源码链接如下

[https://github.com/alibaba/canal](https://github.com/alibaba/canal)

otter源码链接如下

[https://github.com/alibaba/otter](https://github.com/alibaba/otter)

 

第一步 修复源码bug

经过观察，原来是 com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.loadBinlogChecksum 中

columnValues.get(0)没有判空，做如下修改

![](http://dl2.iteye.com/upload/attachment/0123/3208/6149f1d8-b3db-37f9-b51b-1f16ea84cd2d.png)  
 

 

第二步 update otter main pom.xml

![](http://dl2.iteye.com/upload/attachment/0123/3206/4bbee46c-f2fb-3311-9990-f0c1eb6a9c4a.png)  
 

第三步 otter 全部模块 执行 maven update.

 

经本人验证，好用。