Skip to content

fix-385 修复es5和es的sink插件id参数不填时, 报空指针异常 #386

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 9 commits into
base: 1.10_release
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* table output elastic5plugin
Expand Down Expand Up @@ -172,24 +173,17 @@ public void setBulkFlushMaxActions(int bulkFlushMaxActions) {

@Override
public ElasticsearchSink genStreamSink(AbstractTargetTableInfo targetTableInfo) {
ElasticsearchTableInfo elasticsearchTableInfo = (ElasticsearchTableInfo) targetTableInfo;
esTableInfo = elasticsearchTableInfo;
clusterName = elasticsearchTableInfo.getClusterName();
String address = elasticsearchTableInfo.getAddress();
String[] addr = StringUtils.split(address, ",");
esAddressList = Arrays.asList(addr);
index = elasticsearchTableInfo.getIndex();
type = elasticsearchTableInfo.getEsType();
String id = elasticsearchTableInfo.getId();
String[] idField = StringUtils.split(id, ",");
idIndexList = new ArrayList<>();

for(int i = 0; i < idField.length; ++i) {
idIndexList.add(Integer.valueOf(idField[i]));
esTableInfo = (ElasticsearchTableInfo) targetTableInfo;
clusterName = esTableInfo.getClusterName();
index = esTableInfo.getIndex();
type = esTableInfo.getEsType();
columnTypes = esTableInfo.getFieldTypes();
esAddressList = Arrays.asList(esTableInfo.getAddress().split(","));
String id = esTableInfo.getId();

if (!org.apache.commons.lang.StringUtils.isEmpty(id)) {
idIndexList = Arrays.stream(org.apache.commons.lang.StringUtils.split(id, ",")).map(Integer::valueOf).collect(Collectors.toList());
}

columnTypes = elasticsearchTableInfo.getFieldTypes();

return this;
}
}