This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-grpc.git


The following commit(s) were added to refs/heads/main by this push:
     new 6847060f remove ByteArrayInputStream (#504)
6847060f is described below

commit 6847060ff0878fb6c9c670db364c032b7c1d02d7
Author: PJ Fanning <[email protected]>
AuthorDate: Wed Sep 10 10:33:10 2025 +0100

    remove ByteArrayInputStream (#504)
---
 .../grpc/internal/ByteStringInputStream.scala      | 34 ----------------------
 .../org/apache/pekko/grpc/internal/Gzip.scala      |  2 +-
 .../grpc/javadsl/GoogleProtobufSerializer.scala    |  8 +++--
 3 files changed, 6 insertions(+), 38 deletions(-)

diff --git 
a/runtime/src/main/scala/org/apache/pekko/grpc/internal/ByteStringInputStream.scala
 
b/runtime/src/main/scala/org/apache/pekko/grpc/internal/ByteStringInputStream.scala
deleted file mode 100644
index e0d15dfd..00000000
--- 
a/runtime/src/main/scala/org/apache/pekko/grpc/internal/ByteStringInputStream.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * license agreements; and to You under the Apache License, version 2.0:
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * This file is part of the Apache Pekko project, which was derived from Akka.
- */
-
-/*
- * Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
- */
-
-package org.apache.pekko.grpc.internal
-
-import java.io.{ ByteArrayInputStream, InputStream, SequenceInputStream }
-
-import org.apache.pekko
-import pekko.annotation.InternalApi
-import pekko.util.ByteString
-import pekko.util.ByteString.ByteStrings
-import pekko.util.ccompat.JavaConverters._
-
-/** INTERNAL API */
-@InternalApi
-private[grpc] 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/runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala 
b/runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala
index e4aa6f2e..e8f80f99 100644
--- a/runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala
+++ b/runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala
@@ -30,7 +30,7 @@ object Gzip extends Codec {
   }
 
   override def uncompress(compressed: ByteString): ByteString = {
-    val gzis = new GZIPInputStream(ByteStringInputStream(compressed))
+    val gzis = new GZIPInputStream(compressed.asInputStream)
 
     val baos = new ByteArrayOutputStream(compressed.size)
     val buffer = new Array[Byte](32 * 1024)
diff --git 
a/runtime/src/main/scala/org/apache/pekko/grpc/javadsl/GoogleProtobufSerializer.scala
 
b/runtime/src/main/scala/org/apache/pekko/grpc/javadsl/GoogleProtobufSerializer.scala
index dbf2e000..45d28860 100644
--- 
a/runtime/src/main/scala/org/apache/pekko/grpc/javadsl/GoogleProtobufSerializer.scala
+++ 
b/runtime/src/main/scala/org/apache/pekko/grpc/javadsl/GoogleProtobufSerializer.scala
@@ -16,7 +16,6 @@ package org.apache.pekko.grpc.javadsl
 import org.apache.pekko
 import pekko.annotation.ApiMayChange
 import pekko.grpc.ProtobufSerializer
-import pekko.grpc.internal.ByteStringInputStream
 import pekko.util.ByteString
 import com.google.protobuf.Parser
 
@@ -27,8 +26,11 @@ class GoogleProtobufSerializer[T <: 
com.google.protobuf.Message](parser: Parser[
 
   override def serialize(t: T): ByteString =
     ByteString.fromArrayUnsafe(t.toByteArray)
-  override def deserialize(bytes: ByteString): T =
-    parser.parseFrom(ByteStringInputStream(bytes))
+  override def deserialize(bytes: ByteString): T = {
+    val inputStream = bytes.asInputStream
+    try parser.parseFrom(inputStream)
+    finally inputStream.close()
+  }
   override def deserialize(data: InputStream): T =
     parser.parseFrom(data)
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to