Skip to content

Commit

Permalink
Fix ByteBuffer cross-compatibility issues (#128)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Dingilian <[email protected]>
  • Loading branch information
jackdingilian and Jack Dingilian authored Mar 29, 2021
1 parent a216249 commit 60cc377
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package com.spotify.elitzur.converters.avro

import java.nio.ByteBuffer
import java.nio.{Buffer, ByteBuffer}

import org.apache.avro.Schema
import org.apache.avro.generic.{GenericData, GenericRecord, GenericRecordBuilder}
Expand All @@ -40,7 +40,9 @@ object AvroElitzurConversionUtils {
// http://errorprone.info/bugpattern/ByteBufferBackingArray
val bArray = new Array[Byte](bBuffer.remaining)
bBuffer.get(bArray)
bBuffer.position(bBuffer.position() - bArray.length) // Restores position
// cast to Buffer to fix cross-compat issue described
// here: https://stackoverflow.com/questions/61267495
(bBuffer: Buffer).position((bBuffer: Buffer).position() - bArray.length) // Restores position
bArray
}

Expand Down

0 comments on commit 60cc377

Please sign in to comment.