Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vernedeng committed Aug 3, 2024
1 parent 22dfe33 commit 643af9c
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
Expand All @@ -39,6 +40,7 @@
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Slf4j
public class EsIdConfig extends IdConfig {

public static final String PATTERN_DAY = "{yyyyMMdd}";
Expand Down Expand Up @@ -80,6 +82,15 @@ public static EsIdConfig create(DataFlowConfig dataFlowConfig) {
.stream()
.map(FieldConfig::getName)
.collect(Collectors.toList());
Charset charset;
try {
charset = Charset.forName(sinkConfig.getEncodingType());
} catch (Throwable t) {
log.warn("do not support encoding type={}, dataflow id={}",
sinkConfig.getEncodingType(), dataFlowConfig.getDataflowId());
charset = Charset.defaultCharset();
}

return EsIdConfig.builder()
.inlongGroupId(dataFlowConfig.getInlongGroupId())
.inlongStreamId(dataFlowConfig.getInlongStreamId())
Expand All @@ -88,7 +99,7 @@ public static EsIdConfig create(DataFlowConfig dataFlowConfig) {
.separator(sinkConfig.getSeparator())
.indexNamePattern(sinkConfig.getIndexNamePattern())
.fieldList(fields)
.charset(Charset.forName(sinkConfig.getEncodingType()))
.charset(charset)
.build();
}

Expand Down

0 comments on commit 643af9c

Please sign in to comment.