flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tzulitai <...@git.apache.org>
Subject [GitHub] flink pull request #3636: Change to validateOptionalDatePropery method
Date Wed, 29 Mar 2017 14:13:36 GMT
Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3636#discussion_r108686751
  
    --- Diff: flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/util/KinesisConfigUtil.java
---
    @@ -224,15 +224,24 @@ private static void validateOptionalPositiveDoubleProperty(Properties
config, St
     
     	private static void validateOptionalDateProperty(Properties config, String key, String
message) {
     		if (config.containsKey(key)) {
    -			try {
    -				initTimestampDateFormat.parse(config.getProperty(key));
    -				double value = Double.parseDouble(config.getProperty(key));
    -				if (value < 0) {
    -					throw new NumberFormatException();
    +			try{
    +				if(!validateDateFormat(config, key)){
    +					double value = Double.parseDouble(config.getProperty(key));
    +					if (value < 0) {
    +						throw new NumberFormatException();
    +					}
     				}
    -			} catch (ParseException | NumberFormatException e) {
    +			} catch(NumberFormatException){
     				throw new IllegalArgumentException(message);
     			}
     		}
     	}
    +	public static boolean validateDateFormat(Properties config, String key){
    --- End diff --
    
    I don't think it is necessary to have yet another method for this particular case ...
    it can be easily written as 2 catch exception branches, which IMO is easier to understand.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message