There have been strange serialization errors in tests using the InMemoryMessagingNetwork when run in multi-threaded mode. It appears that the root cause is Kryo transiently modifies the source ByteArray. Therefore we must give each thread/node in the network a separate message data copy.

This commit is contained in:
Matthew Nesbit 2016-12-09 16:25:18 +00:00
parent 57975c6e91
commit 6eb74ba10a

View File

@ -374,7 +374,7 @@ class InMemoryMessagingNetwork(val sendManuallyPumped: Boolean) : SingletonSeria
private fun MessageTransfer.toReceivedMessage() = object : ReceivedMessage { private fun MessageTransfer.toReceivedMessage() = object : ReceivedMessage {
override val topicSession: TopicSession get() = message.topicSession override val topicSession: TopicSession get() = message.topicSession
override val data: ByteArray get() = message.data override val data: ByteArray get() = message.data.copyOf() // Kryo messes with the buffer so give each client a unique copy
override val peer: X500Name get() = X509Utilities.getDevX509Name(sender.description) override val peer: X500Name get() = X509Utilities.getDevX509Name(sender.description)
override val debugTimestamp: Instant get() = message.debugTimestamp override val debugTimestamp: Instant get() = message.debugTimestamp
override val uniqueMessageId: UUID get() = message.uniqueMessageId override val uniqueMessageId: UUID get() = message.uniqueMessageId