rootvector2 commented on PR #427:
URL:
https://github.com/apache/commons-beanutils/pull/427#issuecomment-5100706330
The choice here isn't 2 vs 4, it's 1 vs 4. Before the patch
`"first/value,second/value"` parses to `["first"]` and everything after the
first `/` is silently dropped, so nobody gets 2 elements today. The parser has
never kept a symbol inside a token unless it's in `allowedChars`: `_` splits
the same way (`testUnderscore_BEANUTILS_302`, `"first_value,second_value"` is 4
elements, and BEANUTILS-302 was resolved by pointing users at
`setAllowedChars`). `/` was the only char that truncated instead of splitting,
because `StreamTokenizer` defaults to `commentChar('/')`. The patch just puts
`/` on the same footing as every other non-allowed char. The 2-element result
you describe is the opt-in path, same as for `_`: `setAllowedChars(new char[] {
'.', '-', '/' })`, and the second half of the test asserts exactly that
(`["first/value", "second/value"]`).
On `//` and `/* ... */`: those C-style modes are off by default
(`slashSlashComments`/`slashStarComments` are false), so the truncation came
purely from the single-char end-of-line comment. After `ordinaryChar('/')`
there's no comment handling left; `//` or `/*` are just ordinary chars that
split.
If you'd rather make `/` a default allowed char so the out-of-the-box result
is 2 elements, that's a one-line change and I'm happy to switch, but it would
make `/` special compared to `_` and the rest.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]