Open
Description
Describe the bug
Codegen for unions special-cases union members that are blobs to be handled correctly (i.e., by content, not by reference) when calculating hashcode and equality. But it does not account for union members that have nested blobs.
For example, consider DynamoDB's AttributeValue
union:
sealed class AttributeValue {
// This class is correct because the array is properly handled in equals/hashcode
data class B(val value: ByteArray) : AttributeValue() {
override fun hashCode(): Int {
return value.contentHashCode()
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
other as B
if (!value.contentEquals(other.value)) return false
return true
}
}
// This class is correct because non-arrays don't need special handling
data class Bool(val value: Boolean) : AttributeValue()
// This class is incorrect because the arrays are hashed/compared by reference, not by content
data class Bs(val value: List<ByteArray>) : AttributeValue()
}
Expected behavior
The generated code for union members that contain nested blobs should codegen equals/hashcode implementations which verify content equality, not reference equality.
Current behavior
(see above)
Steps to Reproduce
(see above)
Possible Solution
No response
Context
No response
Smithy-Kotlin version
1.3.5
Platform (JVM/JS/Native)
(any)
Operating system and version
(any)