CORDA-2352 Be more lenient with setter property signature validation (#4442)

This commit is contained in:
Dominic Fox 2018-12-19 17:17:01 +00:00 committed by GitHub
parent 466bff4121
commit 9d8618224a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -207,7 +207,9 @@ private data class PropertyNamedMethod(val fieldName: String, val classifier: Me
fun hasValidSignature(): Boolean = method.run {
when (classifier) {
GET -> parameterCount == 0 && returnType != Void.TYPE
SET -> parameterCount == 1 && returnType == Void.TYPE
// We don't check the return type, because some Java frameworks (such as Lombok) generate setters
// with non-void returns for method chaining.
SET -> parameterCount == 1
IS -> parameterCount == 0 &&
(returnType == Boolean::class.java ||
returnType == Boolean::class.javaObjectType)

View File

@ -25,7 +25,12 @@ public class SetterConstructorTests {
public void setA(int a) { this.a = a; }
public void setB(int b) { this.b = b; }
public void setC(int c) { this.c = c; }
// See https://r3-cev.atlassian.net/browse/CORDA-2352
public C setC(int c) {
this.c = c;
return this;
}
}
static class C2 {