[ 
https://issues.apache.org/jira/browse/CHUKWA-642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13484746#comment-13484746
 ] 

Eric Spishak commented on CHUKWA-642:
-------------------------------------

I just attached a new patch with unit tests added.

I was not able to add tests for the changes in 
org/apache/hadoop/chukwa/database/TableCreator.java, 
org/apache/hadoop/chukwa/database/DataExpiration.java and 
org/apache/hadoop/chukwa/dataloader/MetricDataLoader.java because these rely on 
the existence of a jdbc.conf file, which does not come with Chukwa. I also 
noticed that the tests for these classes were excluded from the Maven test task.

And I was not able to add tests for 
org/apache/hadoop/chukwa/datacollection/writer/SocketTeeWriter.java because the 
modified code runs in a different thread than the test, so I had trouble 
figuring out how to verify the correct behavior.

If you have suggestions for how to get around these problems I will gladly add 
additional test cases.
                
> Unvalidated Regular Expression Usage
> ------------------------------------
>
>                 Key: CHUKWA-642
>                 URL: https://issues.apache.org/jira/browse/CHUKWA-642
>             Project: Chukwa
>          Issue Type: Bug
>            Reporter: Eric Spishak
>            Assignee: Eric Spishak
>         Attachments: CHUKWA-642-1.patch, CHUKWA-642-2.patch, CHUKWA-642.patch
>
>
> There are seven additional places in Chukwa where regular expressions are 
> used without first being validated as syntactically valid regular 
> expressions. These could lead to unhelpful PatternSyntaxException strack 
> traces instead of useful error messages. Unfortunately, I was not able to 
> produce test conditions to highlight any of these issues.
> The attached patch fixes the issues. Note that the patch adds a small 
> RegexUtil class with helper methods to determine whether a String is a valid 
> regular expression and to generate error messages for invalid regular 
> expressions. I feel that these helper methods are more readable than catching 
> the PatternSyntaxException. Furthermore, they allow simpler re-use if needed 
> elsewhere.
> I discovered these bugs using a tool named the Regex Checker 
> ([http://types.cs.washington.edu/checker-framework/current/checkers-manual.html#regex-checker]).
>  If you periodically run it on your codebase, then you will learn of other 
> errors like this as soon as they appear.  If you are interested, I can share 
> my annotations for Chukwa, which will enable you to run the Regex Checker 
> yourself without any additional effort.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to