Skip to content

Commit

Permalink
Merge pull request kafka-dev#39 from bmatheny/master
Browse files Browse the repository at this point in the history
Fix a BufferUnderflowException in the StringDecoder
  • Loading branch information
kafka-dev committed Jul 27, 2011
2 parents c272c99 + 2a83c54 commit 12589e2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/src/main/scala/kafka/serializer/Decoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ class DefaultDecoder extends Decoder[Message] {

class StringDecoder extends Decoder[String] {
def toEvent(message: Message):String = {
val messagePayload = message.payload.slice
val dataLength = messagePayload.array.length - messagePayload.arrayOffset
val messageDataArray = new Array[Byte](dataLength)
messagePayload.get(messageDataArray, 0, dataLength)
new String(messageDataArray)
val buf = message.payload
val arr = new Array[Byte](buf.remaining)
buf.get(arr)
new String(arr)
}
}

0 comments on commit 12589e2

Please sign in to comment.