You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by tsriharsha <gi...@git.apache.org> on 2017/03/28 23:58:11 UTC
[GitHub] flink pull request #3636: Change to validateOptionalDatePropery method
GitHub user tsriharsha opened a pull request:
https://github.com/apache/flink/pull/3636
Change to validateOptionalDatePropery method
Current version of validateoptionaldateproperty will fail because it will check for date first and if it passes it will fail to get parsed as a double and so it will fail the next step. Please let me know if this is an accurate statement. I just made a small change, may not follow to the pertaining code format though.
Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration.
If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html).
In addition to going through the list, please provide a meaningful description of your changes.
- [ ] General
- The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text")
- The pull request addresses only one issue
- Each commit in the PR has a meaningful commit message (including the JIRA id)
- [ ] Documentation
- Documentation has been added for new functionality
- Old documentation affected by the pull request has been updated
- JavaDoc for public methods has been added
- [ ] Tests & Build
- Functionality added by the pull request is covered by tests
- `mvn clean verify` has been executed successfully locally or a Travis build has passed
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/tsriharsha/flink patch-1
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/3636.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #3636
----
commit e5ce905d140757e58b173dfc9b7f58724a042e6d
Author: tsriharsha <ts...@gmail.com>
Date: 2017-03-28T23:57:30Z
Change to validateOptionalDatePropery method
Current version of validateoptionaldateproperty will fail because it will check for date first and if it passes it will fail to get parsed as a double and so it will fail the next step. Please let me know if this is an accurate statement. I just made a small change, may not follow to the pertaining code format though.
----
---
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.
---
[GitHub] flink issue #3636: Change to validateOptionalDatePropery method
Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on the issue:
https://github.com/apache/flink/pull/3636
Hi @tsriharsha!
First of all, thanks a lot for reporting this bug. Contributions in Flink, however, require a corresponding JIRA ticket. In the future, I would recommend always opening a JIRA before the pull request so that other contributors will know that the issue is worked on already (and would therefore avoid race conditions / duplicate work like right now :-D).
Generally, the implementation #3637 is cleaner and includes tests for the fix. I think I'll proceed with FLINK-6211 using the patch in #3637. Hope you understand, and welcome more contributions!
---
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.
---
[GitHub] flink pull request #3636: Change to validateOptionalDatePropery method
Posted by tzulitai <gi...@git.apache.org>.
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.
---
[GitHub] flink pull request #3636: Change to validateOptionalDatePropery method
Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on a diff in the pull request:
https://github.com/apache/flink/pull/3636#discussion_r108686349
--- 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 --
Should be `private`.
---
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.
---
[GitHub] flink pull request #3636: Change to validateOptionalDatePropery method
Posted by tzulitai <gi...@git.apache.org>.
Github user tzulitai commented on a diff in the pull request:
https://github.com/apache/flink/pull/3636#discussion_r108686241
--- 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 --
Missing empty line before the method declaration
---
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.
---
[GitHub] flink issue #3636: Change to validateOptionalDatePropery method
Posted by tony810430 <gi...@git.apache.org>.
Github user tony810430 commented on the issue:
https://github.com/apache/flink/pull/3636
Hi @tsriharsha,
Sorry for missing this PR and pushing my patch https://github.com/apache/flink/pull/3637.
I have created a JIRA task ([FLINK-6211](https://issues.apache.org/jira/browse/FLINK-6211)) for it. If you don't mind to update the title and add some tests for this patch, I could close my PR and let you continue working on it.
Thank you.
---
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.
---
[GitHub] flink pull request #3636: Change to validateOptionalDatePropery method
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/flink/pull/3636
---
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.
---