fixed rocketmq ack npe

This commit is contained in:
agapple
2018-11-20 17:14:29 +08:00
parent 43db5bec97
commit b6f1e0d13c

View File

@@ -214,9 +214,13 @@ public class RocketMQCanalConnector implements CanalMQConnector {
@Override @Override
public void ack() throws CanalClientException { public void ack() throws CanalClientException {
try { try {
this.lastGetBatchMessage.ack(); if (this.lastGetBatchMessage != null) {
this.lastGetBatchMessage.ack();
}
} catch (Throwable e) { } catch (Throwable e) {
this.lastGetBatchMessage.fail(); if (this.lastGetBatchMessage != null) {
this.lastGetBatchMessage.fail();
}
} finally { } finally {
this.lastGetBatchMessage = null; this.lastGetBatchMessage = null;
} }
@@ -225,7 +229,9 @@ public class RocketMQCanalConnector implements CanalMQConnector {
@Override @Override
public void rollback() throws CanalClientException { public void rollback() throws CanalClientException {
try { try {
this.lastGetBatchMessage.fail(); if (this.lastGetBatchMessage != null) {
this.lastGetBatchMessage.fail();
}
} finally { } finally {
this.lastGetBatchMessage = null; this.lastGetBatchMessage = null;
} }