Skip to content

Commit cc90994

Browse files
committed
加强属性列和源数据列的校验,不匹配直接失败
1 parent dc77fc1 commit cc90994

File tree

1 file changed

+7
-6
lines changed
  • neo4jwriter/src/main/java/com/alibaba/datax/plugin/writer/neo4jwriter

1 file changed

+7
-6
lines changed

neo4jwriter/src/main/java/com/alibaba/datax/plugin/writer/neo4jwriter/Neo4jClient.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,14 @@ public void tryWrite(Record record) {
198198

199199
private MapValue checkAndConvert(Record record) {
200200
int sourceColNum = record.getColumnNumber();
201-
List<Neo4jProperty> neo4JProperties = writeConfig.neo4jProperties;
202-
203-
int len = Math.min(sourceColNum, neo4JProperties.size());
204-
Map<String, Value> data = new HashMap<>(len * 4 / 3);
205-
for (int i = 0; i < len; i++) {
201+
List<Neo4jProperty> neo4jProperties = writeConfig.neo4jProperties;
202+
if (neo4jProperties == null || neo4jProperties.size() != sourceColNum){
203+
throw new DataXException(Neo4jErrorCode.CONFIG_INVALID,"the read and write columns do not match!");
204+
}
205+
Map<String, Value> data = new HashMap<>(sourceColNum * 4 / 3);
206+
for (int i = 0; i < sourceColNum; i++) {
206207
Column column = record.getColumn(i);
207-
Neo4jProperty neo4jProperty = neo4JProperties.get(i);
208+
Neo4jProperty neo4jProperty = neo4jProperties.get(i);
208209
try {
209210

210211
Value value = ValueAdapter.column2Value(column, neo4jProperty);

0 commit comments

Comments
 (0)