[
https://issues.apache.org/jira/browse/TEXT-219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17618865#comment-17618865
]
Alex Herbert commented on TEXT-219:
-----------------------------------
Thanks for the bug report.
The method now uses:
{code:java}
// Gets a copy of the full token list as an independent modifiable list.
public List<String> getTokenList() {
// ...
return Arrays.asList(tokens);
}{code}
Thus a second bug is that the returned List set method will change the backing
array.
For example this will modify the token order:
{code:java}
StringTokenizer st = ...;
Collections.shuffle(st.getTokenList());
{code}
Please feel free to raise a PR on Github with a test and fix, e.g. return new
ArrayList<>(Arrays.asList(tokens)).
> StringTokenizer#getTokenList does not support #remove
> -----------------------------------------------------
>
> Key: TEXT-219
> URL: https://issues.apache.org/jira/browse/TEXT-219
> Project: Commons Text
> Issue Type: Bug
> Affects Versions: 1.10.0
> Reporter: Jaap Sperling
> Priority: Major
>
> Upgraded to 1.10 from 1.9 and the {{StringTokenizer#getTokenList}} method now
> returns an {{Arrays$ArrayList}} instead of a regular {{{}ArrayList{}}}.
> This causes calls to #add and #remove to throw
> UnsupportedOperationExceptions, even if the documentation states this returns
> modifiable lists
--
This message was sent by Atlassian Jira
(v8.20.10#820010)