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 all commits
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
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.lightbend.paradox.apidoc.ApidocPlugin.autoImport.apidocRootPackage
sourceDistName := "apache-pekko-http"
sourceDistIncubating := false

ThisBuild / resolvers += Resolver.ApacheMavenStagingRepo
ThisBuild / reproducibleBuildsCheckResolver := Resolver.ApacheMavenStagingRepo

addCommandAlias("verifyCodeStyle", "scalafmtCheckAll; scalafmtSbtCheck; +headerCheckAll; javafmtCheckAll")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
package org.apache.pekko.http.impl.engine.http2.hpack

import java.io.{ ByteArrayInputStream, InputStream }
import java.lang.invoke.{ MethodHandles, MethodType }

import scala.util.Try

import org.apache.pekko
import pekko.annotation.InternalApi
Expand All @@ -24,13 +27,32 @@ import pekko.util.ByteString.ByteString1C
@InternalApi
private[http2] object ByteStringInputStream {

def apply(bs: ByteString): InputStream =
bs match {
case cs: ByteString1C =>
// TODO optimise, ByteString needs to expose InputStream (esp if array backed, nice!)
new ByteArrayInputStream(cs.toArrayUnsafe())
case _ =>
// NOTE: We actually measured recently, and compact + use array was pretty good usually
apply(bs.compact)
}
private val byteStringInputStreamMethodTypeOpt = Try {
val lookup = MethodHandles.publicLookup()
val inputStreamMethodType = MethodType.methodType(classOf[InputStream])
lookup.findVirtual(classOf[ByteString], "asInputStream", inputStreamMethodType)
}.toOption

def apply(bs: ByteString): InputStream = bs match {
case cs: ByteString1C =>
getInputStreamUnsafe(cs)
case _ =>
if (byteStringInputStreamMethodTypeOpt.isDefined) {
byteStringInputStreamMethodTypeOpt.get.invoke(bs).asInstanceOf[InputStream]
} else {
asByteArrayInputStream(bs.compact)
}
}

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
getInputStreamUnsafe(bs.compact)
}

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

}
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
2 changes: 1 addition & 1 deletion project/PekkoCoreDependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ import com.github.pjfanning.pekkobuild.PekkoDependency
object PekkoCoreDependency extends PekkoDependency {
override val checkProject: String = "pekko-cluster-sharding-typed"
override val module: Option[String] = None
override val currentVersion: String = "1.0.2"
override val currentVersion: String = "1.1.0-M1-RC1"
}
Loading