Meng-Shuan Tsai created HDDS-16337:
--------------------------------------

             Summary: StorageSize.parse uses untrimmed length after trim and 
fails on whitespace
                 Key: HDDS-16337
                 URL: https://issues.apache.org/jira/browse/HDDS-16337
             Project: Apache Ozone
          Issue Type: Bug
            Reporter: Meng-Shuan Tsai
            Assignee: Meng-Shuan Tsai


This is a bug in {{{}StorageSize.parse{}}}.

The method trims the input into {{sanitizedValue}} and matches the unit suffix 
against that trimmed string. When extracting the numeric part it still uses the 
untrimmed {{value.length()}} as the substring end index:
{code:java}
String sanitizedValue = value.trim().toLowerCase(Locale.ENGLISH);
...
String valString =
    sanitizedValue.substring(0, value.length() - suffix.length());
{code}
[StorageSize.java 
(L47–L90)|https://github.com/apache/ozone/blob/79464b60d7661e89a5d934623a6998f7aff6cbca/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/StorageSize.java#L47-L90]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to