-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Barclay could throw a more helpful error message when trying to populate an immutable list argument field. #100
Comments
(or barclay could just make the Collection mutable by making a mutable copy) |
@droazen, I think that it is safer to disallow immutable collections as default values, because the user may specified it like that as a requirement. If they really need it immutable, they should make their copy by themselves after parsing. If in the case of this issue, using I'll do a PR to catch the |
I'm not sure it makes sense to have an immutable value for a command-line argument. If some tool setting is meant to be immutable, the author should make it a constant rather than a barclay argument. If an immutable collection is being used, it's almost certainly by accident, which is why I think barclay should just auto-convert to a mutable one. @cmnbroad what do you think? |
But if it is by accident, it is better from my point of view to make the user aware that he did it. If not, it is silently doing the conversion. That's why I prefer to throw to make aware the author that he should make it a constant rather than a Barclay argument. See #102 for my proposed solution. |
I think I'd prefer to throw in this case. Otherwise we need to figure out whether or not to preserve existing values based on the intersection of APPEND_TO_COLLECTIONS, and null argument values used to clear. These cases need to be handled in this PR either way, but I think it will be simpler if we just throw. |
Alright, makes sense 👍 |
I noticed that I get a java.lang.UnsupportedOperationException from CommandLineArgumentParser when I have an argument using an immutable list like from
Collections.emptyList().
This throws the following unhelpful stack-trace segment:Since there is no obvious indication of what field is causing the error, this should either throw a more helpful exception pointing to which argument caused the problem or there should be a check that all the requested argument list fields are mutable.
The text was updated successfully, but these errors were encountered: