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

Wrong setter selected in presence of a typed and untyped setter #2385

Closed
jjohannes opened this issue Jul 5, 2017 · 0 comments
Closed

Wrong setter selected in presence of a typed and untyped setter #2385

jjohannes opened this issue Jul 5, 2017 · 0 comments
Assignees
Milestone

Comments

@jjohannes
Copy link
Contributor

Split out from #2239 (comment)

There is an issue with supporting two setters for the same property with different types (see #1866). We need to fix this:

public static PropertyMutator writeablePropertyIfExists(Class<?> target, String property) throws NoSuchPropertyException {
String setterName = toMethodName("set", property);
for (final Method method : target.getMethods()) {
if (!method.getName().equals(setterName) || PropertyAccessorType.of(method) != PropertyAccessorType.SETTER) {
continue;
}
return new MethodBackedPropertyMutator(property, method);
}
return null;
}

At the moment it depends on the order in which methods are iterated if we grep the right one. That explains why it is difficult to reproduce.

Here is a test that fails sometimes, but not always:

def "can always change buildDir in properties file"() {
    when:
    file('gradle.properties') << """
        buildDir=otherBuild
    """
    then:
    succeeds ':help'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant