diff --git a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala index 50839d067f..737d636445 100644 --- a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala +++ b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala @@ -152,7 +152,7 @@ private[remote] class RollingEventLogSection( * sane way to use the same code here and in the test, too. */ def write(logId: Int, recordBuffer: ByteBuffer): Unit = { - val logBuffer = buffers(logId) + val logBuffer: MappedResizeableBuffer = buffers(logId) @tailrec def writeRecord(): Unit = { // Advance the head @@ -162,7 +162,8 @@ private[remote] class RollingEventLogSection( // if the head *wraps over* and points again to this location. Without this we would end up with partial or corrupted // writes to the slot. if (logBuffer.compareAndSetInt(recordOffset, Committed, Dirty)) { - logBuffer.putBytes(payloadOffset, recordBuffer, recordSize) + // 128 bytes total, 4 bytes used for Commit/Dirty flag + logBuffer.putBytes(payloadOffset, recordBuffer, recordSize - 4) //println(logBuffer.getLong(recordOffset + 4)) // Now this is free to be overwritten diff --git a/akka-remote/src/test/scala/akka/remote/artery/FlightRecorderSpec.scala b/akka-remote/src/test/scala/akka/remote/artery/FlightRecorderSpec.scala index 78ba8ec423..9601bd0718 100644 --- a/akka-remote/src/test/scala/akka/remote/artery/FlightRecorderSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/artery/FlightRecorderSpec.scala @@ -358,10 +358,10 @@ class FlightRecorderSpec extends AkkaSpec { channel.force(false) reader.rereadStructure() - reader.structure.loFreqLog.logs(0).richEntries.size should ===(FlightRecorder.LoFreqWindow) + reader.structure.loFreqLog.logs.head.richEntries.size should ===(FlightRecorder.LoFreqWindow) for (i ← 1 to Threads) { - val entries = reader.structure.loFreqLog.logs(0).richEntries.filter(_.code == i).toSeq + val entries = reader.structure.loFreqLog.logs.head.richEntries.filter(_.code == i).toSeq entries.exists(_.dirty) should be(false) // Entries are consecutive for any given writer