garydgregory commented on PR #427:
URL:
https://github.com/apache/commons-beanutils/pull/427#issuecomment-5108743436
@rootvector2
Thank you for your patience reviewing this issue.
Hm, I see what you're saying, but `testUnderscore_BEANUTILS_302` does
further confuse matters, I now believe the fix for `BEANUTILS-302` was
incorrect, incomplete, or misleading.
The intention is stated in the Javadoc:
> Parsing Delimited Lists
This implementation can convert a delimited list in String format into an
array of the appropriate type. By default, it uses a comma as the delimiter but
the following methods can be used to configure parsing:
setDelimiter(char) - allows the character used as the delimiter to be
configured [default is a comma].
setAllowedChars(char[]) - adds additional characters (to the default
alphabetic/numeric) to those considered to be valid token characters.
and the setters:
```java
/**
* Sets the allowed characters to be used for parsing a delimited String.
*
* @param allowedChars Characters which are to be considered as part of
the tokens when parsing a delimited String [default is '.' and '-']
*/
public void setAllowedChars(final char[] allowedChars) {
this.allowedChars = Objects.requireNonNull(allowedChars,
"allowedChars").clone();
}
/**
* Sets the delimiter to be used for parsing a delimited String.
*
* @param delimiter The delimiter [default ',']
*/
public void setDelimiter(final char delimiter) {
this.delimiter = delimiter;
}
```
So, by default there is only _one_ delimiter: `,`. This tells me both
`testUnderscore_BEANUTILS_302` and this PR are wrong and surprisingly wrong to
boot, to my eye that is.
`"first_value,second_value"` and `"first/value,second/value"` should both
parse to 2 elements, not 4.
The fact that the internals use a string tokenizer is an implementation
detail, likely because this code was written before Java implemented a regex
API. If using a regex API is better (split or Pattern), then let's do that.
WDYT?
--
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]