Skip to content

Commit 85640b5

Browse files
committed
【opt】add timezone check
1 parent 3384b86 commit 85640b5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

core/src/main/java/com/dtstack/flink/sql/exec/ExecuteProcessHelper.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@
7171
import java.net.URLClassLoader;
7272
import java.net.URLDecoder;
7373
import java.time.ZoneId;
74-
import java.util.Arrays;
75-
import java.util.List;
76-
import java.util.Map;
77-
import java.util.Properties;
78-
import java.util.Set;
74+
import java.util.*;
7975

8076
/**
8177
* 任务执行时的流程方法
@@ -358,11 +354,19 @@ private static StreamTableEnvironment getStreamTableEnv(StreamExecutionEnvironme
358354

359355
TableConfig tableConfig = new TableConfig();
360356

357+
timeZoneCheck(confProperties.getProperty(TIME_ZONE));
358+
361359
tableConfig.setLocalTimeZone(ZoneId.of(confProperties.getProperty(TIME_ZONE)));
362360

363361
StreamTableEnvironment tableEnv = StreamTableEnvironmentImpl.create(env, settings, tableConfig);
364362
StreamEnvConfigManager.streamTableEnvironmentStateTTLConfig(tableEnv, confProperties);
365363
return tableEnv;
366364
}
367365

366+
private static void timeZoneCheck(String timeZone) {
367+
ArrayList<String> zones = Lists.newArrayList(TimeZone.getAvailableIDs());
368+
if (!zones.contains(timeZone)){
369+
throw new IllegalArgumentException(" timezone is Incorrect!");
370+
}
371+
}
368372
}

0 commit comments

Comments
 (0)