diff --git a/pekko-http-avro4s/src/main/scala/com/github/pjfanning/pekkohttpavro4s/AvroSupport.scala b/pekko-http-avro4s/src/main/scala/com/github/pjfanning/pekkohttpavro4s/AvroSupport.scala index a67c0c0..7aa6dc9 100644 --- a/pekko-http-avro4s/src/main/scala/com/github/pjfanning/pekkohttpavro4s/AvroSupport.scala +++ b/pekko-http-avro4s/src/main/scala/com/github/pjfanning/pekkohttpavro4s/AvroSupport.scala @@ -111,7 +111,7 @@ trait AvroSupport { val schema = AvroSchema[A] Try { - val bytes = bs.toArray + val bytes = bs.toArrayUnsafe if (bytes.length == 0) throw Unmarshaller.NoContentException AvroInputStream.json[A].from(bytes).build(schema).iterator.next() } diff --git a/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala b/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala index a9beaa5..afc1cba 100644 --- a/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala +++ b/pekko-http-jackson/src/main/scala/com/github/pjfanning/pekkohttpjackson/JacksonSupport.scala @@ -205,7 +205,7 @@ trait JacksonSupport { objectMapper: ObjectMapper with ClassTagExtensions = defaultObjectMapper ): Unmarshaller[ByteString, A] = Unmarshaller { _ => bs => - Future.fromTry(Try(objectMapper.readValue[A](bs.toArray))) + Future.fromTry(Try(objectMapper.readValue[A](bs.toArrayUnsafe))) } /** diff --git a/pekko-http-jsoniter-scala/src/main/scala/com/github/pjfanning/pekkohttpjsoniterscala/JsoniterScalaSupport.scala b/pekko-http-jsoniter-scala/src/main/scala/com/github/pjfanning/pekkohttpjsoniterscala/JsoniterScalaSupport.scala index 570789f..6ab7828 100644 --- a/pekko-http-jsoniter-scala/src/main/scala/com/github/pjfanning/pekkohttpjsoniterscala/JsoniterScalaSupport.scala +++ b/pekko-http-jsoniter-scala/src/main/scala/com/github/pjfanning/pekkohttpjsoniterscala/JsoniterScalaSupport.scala @@ -136,7 +136,7 @@ trait JsoniterScalaSupport { codec: JsonValueCodec[A], config: ReaderConfig = defaultReaderConfig ): Unmarshaller[ByteString, A] = - Unmarshaller(_ => bs => Future.fromTry(Try(readFromArray(bs.toArray, config)))) + Unmarshaller(_ => bs => Future.fromTry(Try(readFromArray(bs.toArrayUnsafe, config)))) /** * HTTP entity => `Source[A, _]` diff --git a/pekko-http-ninny/src/main/scala/com/github/pjfanning/pekkohttpninny/NinnySupport.scala b/pekko-http-ninny/src/main/scala/com/github/pjfanning/pekkohttpninny/NinnySupport.scala index fc66c63..56ce57f 100644 --- a/pekko-http-ninny/src/main/scala/com/github/pjfanning/pekkohttpninny/NinnySupport.scala +++ b/pekko-http-ninny/src/main/scala/com/github/pjfanning/pekkohttpninny/NinnySupport.scala @@ -91,7 +91,7 @@ trait NinnySupport { */ implicit def fromByteStringUnmarshaller[A: FromJson]: Unmarshaller[ByteString, A] = Unmarshaller(_ => - bs => Future.fromTry(Json.parse(new String(bs.toArray, StandardCharsets.UTF_8)).to[A]) + bs => Future.fromTry(Json.parse(new String(bs.toArrayUnsafe, StandardCharsets.UTF_8)).to[A]) ) /** diff --git a/pekko-http-play-json/src/main/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupport.scala b/pekko-http-play-json/src/main/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupport.scala index db77c9f..250f0de 100644 --- a/pekko-http-play-json/src/main/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupport.scala +++ b/pekko-http-play-json/src/main/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupport.scala @@ -140,7 +140,7 @@ trait PlayJsonSupport { * unmarshaller for any `A` value */ implicit def fromByteStringUnmarshaller[A: Reads]: Unmarshaller[ByteString, A] = - Unmarshaller(_ => bs => Future.fromTry(Try(Json.parse(bs.toArray).as[A]))) + Unmarshaller(_ => bs => Future.fromTry(Try(Json.parse(bs.toArrayUnsafe).as[A]))) /** * HTTP entity => `Source[A, _]` diff --git a/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala b/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala index 8ed84be..953f316 100644 --- a/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala +++ b/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala @@ -110,7 +110,7 @@ trait UpickleCustomizationSupport { * unmarshaller for any `A` value */ implicit def fromByteStringUnmarshaller[A: api.Reader]: Unmarshaller[ByteString, A] = - Unmarshaller(_ => bs => Future.fromTry(Try(api.read(bs.toArray)))) + Unmarshaller(_ => bs => Future.fromTry(Try(api.read(bs.toArrayUnsafe)))) /** * HTTP entity => `A`