From 8c495117ee17d9ccf5817d536e0accd2f293f148 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 1 Oct 2024 23:22:16 +0100 Subject: [PATCH] pekko 1.1 (#29) * pekko 1.1 * remove ByteStringInputStream * Update build.sbt * Update build.sbt --- build.sbt | 4 +- .../pekkohttpavro4s/AvroSupport.scala | 3 +- .../ByteStringInputStream.scala | 41 ------------------- .../pekkohttpplayjson/PlayJsonSupport.scala | 3 +- .../ByteStringInputStream.scala | 41 ------------------- 5 files changed, 4 insertions(+), 88 deletions(-) delete mode 100644 pekko-http-avro4s/src/main/scala/org/apache/pekko/pekkohttpavro4s/ByteStringInputStream.scala delete mode 100644 pekko-http-play-json/src/main/scala/org/apache/pekko/pekkohttpplayjson/ByteStringInputStream.scala diff --git a/build.sbt b/build.sbt index c8ba638..f2400ac 100644 --- a/build.sbt +++ b/build.sbt @@ -222,8 +222,8 @@ lazy val commonSettings = lazy val library = new { object Version { - val pekko = "1.0.3" - val pekkoHttp = "1.0.1" + val pekko = "1.1.1" + val pekkoHttp = "1.1.0" val argonaut = "6.3.10" val avro4s = "4.1.2" val circe = "0.14.10" 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 d4a6085..21e59b8 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 @@ -27,7 +27,6 @@ import org.apache.pekko.http.scaladsl.unmarshalling.{ Unmarshaller } import org.apache.pekko.http.scaladsl.util.FastFuture -import org.apache.pekko.pekkohttpavro4s.ByteStringInputStream import org.apache.pekko.stream.scaladsl.{ Flow, Source } import org.apache.pekko.util.ByteString import com.sksamuel.avro4s.{ @@ -113,7 +112,7 @@ trait AvroSupport { if (bs.isEmpty) throw Unmarshaller.NoContentException AvroInputStream .json[A] - .from(ByteStringInputStream(bs)) + .from(bs.asInputStream) .build(schema) .iterator .next() diff --git a/pekko-http-avro4s/src/main/scala/org/apache/pekko/pekkohttpavro4s/ByteStringInputStream.scala b/pekko-http-avro4s/src/main/scala/org/apache/pekko/pekkohttpavro4s/ByteStringInputStream.scala deleted file mode 100644 index 83d8dd4..0000000 --- a/pekko-http-avro4s/src/main/scala/org/apache/pekko/pekkohttpavro4s/ByteStringInputStream.scala +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.pekko.pekkohttpavro4s - -import org.apache.pekko.annotation.InternalApi -import org.apache.pekko.util.ByteString -import org.apache.pekko.util.ByteString.ByteStrings - -import java.io.{ ByteArrayInputStream, InputStream, SequenceInputStream } -import scala.collection.JavaConverters._ - -/** - * INTERNAL API - * - * Helper to create an InputStream from a ByteString. Needs to be in the same package as ByteString - * to access the package-private ByteString methods. - */ -@InternalApi -object ByteStringInputStream { - def apply(bs: ByteString): InputStream = bs match { - case bss: ByteStrings => - new SequenceInputStream(bss.bytestrings.iterator.map(apply).asJavaEnumeration) - case _ => - new ByteArrayInputStream(bs.toArrayUnsafe()) - } -} 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 f126f88..bef38a0 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 @@ -28,7 +28,6 @@ import org.apache.pekko.http.scaladsl.model.{ import org.apache.pekko.http.scaladsl.model.MediaTypes.`application/json` import org.apache.pekko.http.scaladsl.unmarshalling._ import org.apache.pekko.http.scaladsl.util.FastFuture -import org.apache.pekko.pekkohttpplayjson.ByteStringInputStream import org.apache.pekko.stream.scaladsl.{ Flow, Source } import org.apache.pekko.util.ByteString import play.api.libs.json.{ JsError, JsResultException, JsValue, Json, Reads, Writes } @@ -141,7 +140,7 @@ trait PlayJsonSupport { * unmarshaller for any `A` value */ implicit def fromByteStringUnmarshaller[A: Reads]: Unmarshaller[ByteString, A] = - Unmarshaller(ec => bs => Future(Json.parse(ByteStringInputStream(bs)).as[A])(ec)) + Unmarshaller(ec => bs => Future(Json.parse(bs.asInputStream).as[A])(ec)) /** * HTTP entity => `Source[A, _]` diff --git a/pekko-http-play-json/src/main/scala/org/apache/pekko/pekkohttpplayjson/ByteStringInputStream.scala b/pekko-http-play-json/src/main/scala/org/apache/pekko/pekkohttpplayjson/ByteStringInputStream.scala deleted file mode 100644 index d5d0d04..0000000 --- a/pekko-http-play-json/src/main/scala/org/apache/pekko/pekkohttpplayjson/ByteStringInputStream.scala +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.pekko.pekkohttpplayjson - -import org.apache.pekko.annotation.InternalApi -import org.apache.pekko.util.ByteString -import org.apache.pekko.util.ByteString.ByteStrings - -import java.io.{ ByteArrayInputStream, InputStream, SequenceInputStream } -import scala.collection.JavaConverters._ - -/** - * INTERNAL API - * - * Helper to create an InputStream from a ByteString. Needs to be in the same package as ByteString - * to access the package-private ByteString methods. - */ -@InternalApi -object ByteStringInputStream { - def apply(bs: ByteString): InputStream = bs match { - case bss: ByteStrings => - new SequenceInputStream(bss.bytestrings.iterator.map(apply).asJavaEnumeration) - case _ => - new ByteArrayInputStream(bs.toArrayUnsafe()) - } -}