You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "Marcono1234 (Jira)" <ji...@apache.org> on 2021/02/20 18:43:00 UTC

[jira] [Created] (HDFS-15844) TestPlanner uses wrong regex pattern

Marcono1234 created HDFS-15844:
----------------------------------

             Summary: TestPlanner uses wrong regex pattern
                 Key: HDFS-15844
                 URL: https://issues.apache.org/jira/browse/HDFS-15844
             Project: Hadoop HDFS
          Issue Type: Bug
            Reporter: Marcono1234


The test class {{org.apache.hadoop.hdfs.server.diskbalancer.TestPlanner}} uses multiple times the regex patterns:
{code}
33.[2|3|4] G
{code}
{code}
18.[6|7|8] G
{code}
There are two issues with this:
- {{.}} matches any character, however it appears the test expects a literal {{.}}, therefore it should escape it:
{code}
\.
{code}
- {{[...]}} is a character class which matches any of the contained characters litereally (with some exceptions). Therefore this allows the character {{|}} literally, and duplicates it even though listing it once would be enough. The tests probably expect only one of the numbers, so {{|}} should be removed:
{code}
[234]
{code}

To demonstrate that the patterns are incorrect:
{code}
String invalid = "33@| G";
invalid.matches("33.[2|3|4] G");
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-help@hadoop.apache.org