kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nehanarkh...@apache.org
Subject svn commit: r1303890 - /incubator/kafka/trunk/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala
Date Thu, 22 Mar 2012 16:59:12 GMT
Author: nehanarkhede
Date: Thu Mar 22 16:59:11 2012
New Revision: 1303890

URL: http://svn.apache.org/viewvc?rev=1303890&view=rev
Log:
KAFKA-309 Bug in FileMessageSet's append API can corrupt on disk log; patched by nehanarkhede;
reviewed by junrao

Modified:
    incubator/kafka/trunk/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala

Modified: incubator/kafka/trunk/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala
URL: http://svn.apache.org/viewvc/incubator/kafka/trunk/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala?rev=1303890&r1=1303889&r2=1303890&view=diff
==============================================================================
--- incubator/kafka/trunk/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala (original)
+++ incubator/kafka/trunk/core/src/main/scala/kafka/message/ByteBufferMessageSet.scala Thu
Mar 22 16:59:11 2012
@@ -72,8 +72,12 @@ class ByteBufferMessageSet(private val b
   }
   
   /** Write the messages in this set to the given channel */
-  def writeTo(channel: GatheringByteChannel, offset: Long, size: Long): Long =
-    channel.write(buffer.duplicate)
+  def writeTo(channel: GatheringByteChannel, offset: Long, size: Long): Long = {
+    buffer.mark()
+    val written = channel.write(buffer)
+    buffer.reset()
+    written
+  }
   
   override def iterator: Iterator[MessageAndOffset] = internalIterator()
 



Mime
View raw message