You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/09/27 10:33:02 UTC

[GitHub] [commons-csv] mykolaf opened a new pull request, #266: Check setDelimiter() for empty string

mykolaf opened a new pull request, #266:
URL: https://github.com/apache/commons-csv/pull/266

   Signed-off-by: Mykola Faryma <m....@partner.samsung.com>
   
   The addition of String delimiter support opened a new opportunity to set the delimiter as empty string. This situation will result in `NegativeArraySizeException` (see example below). I propose to enhance argument checking in `setDelimiter(String delimiter)` to get explicit and helpful exception in such case. 
   
   Log:
   ```
   Exception in thread "main" java.lang.NegativeArraySizeException: -1
           at org.apache.commons.csv.Lexer.<init>(Lexer.java:75)
           at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:435)
           at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:403)
           at org.apache.commons.csv.CSVParser.parse(CSVParser.java:303)
           at Test.main(Test.java:10)
   ```
   Test code:
   ```
   import org.apache.commons.csv.CSVFormat;
   import org.apache.commons.csv.CSVParser;
   
   import java.io.StringReader;
   
   public class Test {
       public static void main(String[] args) throws Exception {
   
           CSVParser.parse("abcd", CSVFormat.Builder.create().setDelimiter("").build());
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-csv] garydgregory merged pull request #266: Validate input to setDelimiter(String) for empty string

Posted by GitBox <gi...@apache.org>.
garydgregory merged PR #266:
URL: https://github.com/apache/commons-csv/pull/266


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org