-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use ByteStringInputStream * unused import * rework legacyConvert Co-Authored-By: João Ferreira <[email protected]> * simpler code Co-Authored-By: João Ferreira <[email protected]> --------- Co-authored-by: João Ferreira <[email protected]>
- Loading branch information
1 parent
2ef115e
commit 6221aa6
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
runtime/src/main/scala/org/apache/pekko/grpc/internal/ByteStringInputStream.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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[internal] 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()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters