Skip to content

Commit

Permalink
[chore] add warn log
Browse files Browse the repository at this point in the history
  • Loading branch information
ashulin committed Mar 17, 2023
1 parent cf935b8 commit ce98161
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public <T> Optional<T> getOptional(Option<T> option) {
if (value == null) {
return Optional.empty();
}
return Optional.of(convertValue(value, option.typeReference()));
return Optional.of(convertValue(value, option));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import org.apache.seatunnel.shade.com.typesafe.config.Config;
import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;

import org.apache.seatunnel.api.configuration.Option;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -33,6 +37,7 @@
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
public class ConfigUtil {
private static final JavaPropsMapper PROPERTIES_MAPPER = new JavaPropsMapper();
private static final ObjectMapper JACKSON_MAPPER = new ObjectMapper();
Expand Down Expand Up @@ -113,7 +118,8 @@ static Object flatteningMapWithObject(Object rawValue) {
}

@SuppressWarnings("unchecked")
public static <T> T convertValue(Object rawValue, TypeReference<T> typeReference) {
public static <T> T convertValue(Object rawValue, Option<T> option) {
TypeReference<T> typeReference = option.typeReference();
rawValue = flatteningMapWithObject(rawValue);
if (typeReference.getType() instanceof Class) {
// simple type
Expand All @@ -135,6 +141,10 @@ public static <T> T convertValue(Object rawValue, TypeReference<T> typeReference
&& List.class.equals(
((ParameterizedType) typeReference.getType()).getRawType())) {
try {
log.warn(
String.format(
"Option '%s' is a List, and it is recommended to configure it as [\"string1\",\"string2\"]; we will only use ',' to split the String into a list.",
option.key()));
return (T)
convertToList(
rawValue,
Expand Down

0 comments on commit ce98161

Please sign in to comment.