Open sterien7 opened 4 years ago
I came up with an idea. I though what if I had the exact object copied to a new one and I created a method
fun <T : Serializable> deepCopy(obj: T?): T? {
if (obj == null) return null
val baos = ByteArrayOutputStream()
val oos = ObjectOutputStream(baos)
oos.writeObject(obj)
oos.close()
val bais = ByteArrayInputStream(baos.toByteArray())
val ois = ObjectInputStream(bais)
@Suppress("unchecked_cast")
return ois.readObject() as T
}
after using this method in order to create the UserRelationship that I POST to the server, everything worked. So I think it has something to do with retrofit and the way it handles the data sent over HTTP
Is that helpfull?
I have problems trying to do the following in my app in Kotlin I have 2 objects, User and UserRelationship
The task needed it to search if userA has a relationship with userB and then update it so the code I execute is
and after that I execute the http request
The request executes without a problem and returns the relationship object. The problem is than now userA.document = null but userB.document is not null
any ideas