Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOT FOR MERGE] test with 1.1.0-M1-RC1 #548

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,34 @@
if (byteStringInputStreamMethodTypeOpt.isDefined) {
byteStringInputStreamMethodTypeOpt.get.invoke(bs).asInstanceOf[InputStream]
} else {
legacyConvert(bs.compact)
asByteArrayInputStream(bs.compact)
}
}

private def legacyConvert(bs: ByteString): InputStream = bs match {
def asByteArrayInputStream(bs: ByteString): ByteArrayInputStream = bs match {
case cs: ByteString1C =>
getInputStreamUnsafe(cs)
case _ =>
// NOTE: We actually measured recently, and compact + use array was pretty good usually
legacyConvert(bs.compact)
getInputStreamUnsafe(bs.compact)
}

private def getInputStreamUnsafe(bs: ByteString): InputStream =
private def getInputStreamUnsafe(bs: ByteString): ByteArrayInputStream =
new ByteArrayInputStream(bs.toArrayUnsafe())

private def asString(stream: InputStream): String = {

Check warning on line 58 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/ByteStringInputStream.scala

View workflow job for this annotation

GitHub Actions / validate-links

private method asString in object ByteStringInputStream is never used

Check warning on line 58 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/ByteStringInputStream.scala

View workflow job for this annotation

GitHub Actions / Compile and test (2.13, 8)

private method asString in object ByteStringInputStream is never used

Check warning on line 58 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/ByteStringInputStream.scala

View workflow job for this annotation

GitHub Actions / Compile and test (2.12, 8)

private method asString in object ByteStringInputStream is never used

Check warning on line 58 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/ByteStringInputStream.scala

View workflow job for this annotation

GitHub Actions / Compile and test (2.12, 11)

private method asString in object ByteStringInputStream is never used

Check warning on line 58 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/ByteStringInputStream.scala

View workflow job for this annotation

GitHub Actions / Compile and test (2.13, 11)

private method asString in object ByteStringInputStream is never used
val bos = new java.io.ByteArrayOutputStream()
val array = new Array[Byte](4096)
try {
var n = stream.read(array)
while (n != -1) {
bos.write(array, 0, n)
n = stream.read(array)
}
bos.toString("UTF-8")
} finally {
bos.close()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private[http2] final class HeaderDecompression(masterHeaderParser: HttpHeaderPar
}
}
try {
decoder.decode(ByteStringInputStream(payload), Receiver)
decoder.decode(ByteStringInputStream.asByteArrayInputStream(payload), Receiver)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

decoder.endHeaderBlock() // TODO: do we have to check the result here?

push(eventsOut, ParsedHeadersFrame(streamId, endStream, headers.result(), prioInfo))
Expand Down
Loading