Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
fix field charset
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Nov 15, 2022
1 parent 017ddec commit 09a0894
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.alibaba.otter.canal.parse.inbound.oceanbase.logproxy;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.sql.Types;
import java.util.Arrays;
Expand Down Expand Up @@ -155,7 +156,7 @@ public void reset() {

}

private CanalEntry.Entry parseDmlRecord(LogMessage message, CanalEntry.EventType eventType) {
private CanalEntry.Entry parseDmlRecord(LogMessage message, CanalEntry.EventType eventType) throws UnsupportedEncodingException {
messageCount();
if (filterQueryDml || (filterDmlInsert && eventType.equals(CanalEntry.EventType.INSERT)) || (filterDmlUpdate
&& eventType.equals(
Expand Down Expand Up @@ -274,7 +275,7 @@ private CanalEntry.Header createHeader(LogMessage message, CanalEntry.EventType
return headerBuilder.build();
}

private CanalEntry.RowData dmlRowData(LogMessage message) {
private CanalEntry.RowData dmlRowData(LogMessage message) throws UnsupportedEncodingException {
String name = message.getDbName() + "." + message.getTableName();
List<String> fieldWhiteList = fieldFilterMap.get(name.toUpperCase());
List<String> fieldBlackList = fieldBlackFilterMap.get(name.toUpperCase());
Expand Down Expand Up @@ -309,10 +310,12 @@ private CanalEntry.RowData dmlRowData(LogMessage message) {
//columnBuilder.setValue(field.getValue().toString(charset.name()));
//判断是否是BLOB类型
if (JAVA_TYPE.getOrDefault(field.getType(), 0) == Types.BLOB) {
// columnBuilder.setValue(new string(field.getValue().getBytes(), "UTF8"));
columnBuilder.setValue(new String(field.getValue().getBytes(), StandardCharsets.ISO_8859_1));
// columnBuilder.setValue(new string(field.getValue().getBytes(), "UTF8"));
columnBuilder.setValue(new String(field.getValue().getBytes(), StandardCharsets.ISO_8859_1));
} else if ("binary".equals(field.encoding)) {
columnBuilder.setValue(new String(field.getValue().getBytes(), charset));
} else {
columnBuilder.setValue(field.getValue().toString(charset.name()));
columnBuilder.setValue(field.getValue().toString(StringUtils.isNotBlank(field.encoding) ? field.encoding : charset.name()));
}
}

Expand Down

0 comments on commit 09a0894

Please sign in to comment.