Skip to content
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

Mutexes don't null out default arguments #143

Open
helgridly opened this issue Aug 14, 2018 · 2 comments
Open

Mutexes don't null out default arguments #143

helgridly opened this issue Aug 14, 2018 · 2 comments

Comments

@helgridly
Copy link

I had the following setup (extremely contrived):

@Argument(mutex = {"TWO", "THREE"})
public Integer ONE = 1;

@Argument(mutex = {"ONE", "THREE"})
public Integer TWO = null;

@Argument(mutex = {"ONE", "TWO"})
public Integer THREE = null;

Integer getNumber() {
	if( ONE != null ) {
		return ONE;
	} else if( TWO != null ) {
		return TWO;
	} else {
		return THREE;
	}
}

I passed TWO=2 on the command line and... getNumber() returns 1.

I had assumed that if I set up mutexes, only one of the arguments would ever be able to be defined. I was extremely wrong and this subtly broke my application until I noticed identical results when I didn't expect them.

Two options, I think:

  1. If the user defines a mutex'd argument, set the other arguments all to null, regardless of their defaults.
  2. Document that mutex only applies to what the user types, and that default arguments will remain defined even if the user defines one of the mutex.
@cmnbroad
Copy link
Collaborator

Yeah, the intention is that mutex applies to what the user is required to provide. FWIW, in your example, the mutex args are required, so the user is required provide at least one of them, making the initial values unnecessary. (Having said that, I take your point that the behavior wan't clear and should be documented better...)

@helgridly
Copy link
Author

Good point. Apparently I also assumed that if the user didn't pass anything, it'd fall back to the value that had the default defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants