Changed the Groovy equals & hashcode usage to manual one

there's a bug in Groovy with autogenerated hashCode and byte arrays
to fix it we've migrated from the AST to manual hashcode and equals generation

fixes gh-546
This commit is contained in:
Marcin Grzejszczak
2018-03-21 14:03:06 +01:00
parent 0078230492
commit 297ee8e2ea
3 changed files with 90 additions and 13 deletions

View File

@@ -17,7 +17,6 @@
package org.springframework.cloud.contract.spec.internal
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
/**
* Represents an element of a DSL that can contain client or sever side values
@@ -25,7 +24,6 @@ import groovy.transform.ToString
* @since 1.0.0
*/
@CompileStatic
@EqualsAndHashCode
@ToString(includePackage = false, includeNames = true)
class DslProperty<T> {
@@ -47,4 +45,20 @@ class DslProperty<T> {
(this.clientValue != null && this.serverValue == null ) ||
(this.serverValue != null && this.clientValue == null )
}
boolean equals(o) {
if (this.is(o)) return true
if (getClass() != o.class) return false
DslProperty that = (DslProperty) o
if (this.clientValue != that.clientValue) return false
if (this.serverValue != that.serverValue) return false
return true
}
int hashCode() {
int result
result = (this.clientValue != null ? this.clientValue.hashCode() : 0)
result = 31 * result + (this.serverValue != null ? this.serverValue.hashCode() : 0)
return result
}
}