Skip to content

Commit

Permalink
Fix compiler warnings (#3344)
Browse files Browse the repository at this point in the history
  • Loading branch information
ennru committed Jul 6, 2020
1 parent b2ea74e commit d971d23
Show file tree
Hide file tree
Showing 39 changed files with 95 additions and 98 deletions.
Expand Up @@ -99,7 +99,7 @@ abstract class Cache[K, V] extends akka.http.caching.javadsl.Cache[K, V] {
* Returns either the cached CompletionStage for the given key or the given value as a CompletionStage
*/
override def getOrCreateStrict(key: K, block: Creator[V]): CompletionStage[V] =
futureToJava(get(key, () => block.create))
futureToJava(get(key, () => block.create()))

/**
* Returns the upper bound for the number of currently cached entries.
Expand Down
Expand Up @@ -224,7 +224,7 @@ private[http] final class PoolMasterActor extends Actor with ActorLogging {

private[http] object PoolMasterActor {

val props = Props[PoolMasterActor].withDeploy(Deploy.local)
val props = Props[PoolMasterActor]().withDeploy(Deploy.local)

sealed trait PoolInterfaceStatus
final case class PoolInterfaceRunning(interface: PoolInterface) extends PoolInterfaceStatus
Expand Down
Expand Up @@ -118,10 +118,10 @@ private[http] trait HttpMessageParser[Output >: MessageOutput <: ParserOutput] {
protocol = c(7) match {
case '0' => `HTTP/1.0`
case '1' => `HTTP/1.1`
case _ => onBadProtocol
case _ => onBadProtocol()
}
cursor + 8
} else onBadProtocol
} else onBadProtocol()
}

/**
Expand Down
Expand Up @@ -114,7 +114,7 @@ private[http] class HttpResponseParser(protected val settings: ParserSettings, p
// Status format with no reason phrase and no trailing space accepted, diverging from the spec
// See https://github.com/akka/akka-http/pull/989
skipNewLine(cursor + 3)
} else badStatusCode
} else badStatusCode()
}

def handleInformationalResponses: Boolean = true
Expand Down
Expand Up @@ -307,7 +307,7 @@ private[http] class ByteStringRendering(sizeHint: Int) extends Rendering {
private[this] val builder = new ByteStringBuilder
builder.sizeHint(sizeHint)

def get: ByteString = builder.result
def get: ByteString = builder.result()

def ~~(char: Char): this.type = {
builder += char.toByte
Expand Down
Expand Up @@ -71,7 +71,7 @@ package object util {
if (bytes >= unit) {
val exp = (math.log(bytes.toDouble) / math.log(unit)).toInt
val pre = if (si) "kMGTPE".charAt(exp - 1).toString else "KMGTPE".charAt(exp - 1).toString + 'i'
"%.1f %sB" format (bytes / math.pow(unit, exp), pre)
"%.1f %sB".format(bytes / math.pow(unit, exp), pre)
} else bytes.toString + " B"
}

Expand Down
Expand Up @@ -481,7 +481,7 @@ class HttpExt private[http] (private val config: Config)(implicit val system: Ex
private[akka] def newHostConnectionPool[T](setup: HostConnectionPoolSetup)(
implicit
fm: Materializer): Flow[(HttpRequest, T), (Try[HttpResponse], T), HostConnectionPool] = {
val poolId = new PoolId(setup, PoolId.newUniquePool)
val poolId = new PoolId(setup, PoolId.newUniquePool())
poolMaster.startPool(poolId)
poolClientFlow(poolId)
}
Expand Down
Expand Up @@ -99,7 +99,7 @@ sealed trait BinaryMessage extends akka.http.javadsl.model.ws.BinaryMessage with
case BinaryMessage.Streamed(binaryStream) => binaryStream
.completionTimeout(timeout)
.runFold(new ByteStringBuilder())((b, e) => b.append(e))
.map(b => b.result)(fm.executionContext)
.map(b => b.result())(fm.executionContext)
.map(binary => BinaryMessage.Strict(binary))(fm.executionContext)
}

Expand Down
Expand Up @@ -642,7 +642,7 @@ class NewConnectionPoolSpec extends AkkaSpecWithMaterializer("""
def mapServerSideOutboundRawBytes(bytes: ByteString): ByteString = bytes

val incomingConnectionCounter = new AtomicInteger
val incomingConnections = TestSubscriber.manualProbe[Http.IncomingConnection]
val incomingConnections = TestSubscriber.manualProbe[Http.IncomingConnection]()
val (incomingConnectionsSub, serverHostName: String, serverPort: Int) = {
val rawBytesInjection = BidiFlow.fromFlows(
Flow[SslTlsOutbound].collect[ByteString] { case SendBytes(x) => mapServerSideOutboundRawBytes(x) }
Expand Down Expand Up @@ -729,7 +729,7 @@ class NewConnectionPoolSpec extends AkkaSpecWithMaterializer("""

def flowTestBench[T, Mat](poolFlow: Flow[(HttpRequest, T), (Try[HttpResponse], T), Mat]) = {
val requestIn = TestPublisher.probe[(HttpRequest, T)]()
val responseOut = TestSubscriber.manualProbe[(Try[HttpResponse], T)]
val responseOut = TestSubscriber.manualProbe[(Try[HttpResponse], T)]()
val hcp = Source.fromPublisher(requestIn).viaMat(poolFlow)(Keep.right).to(Sink.fromSubscriber(responseOut)).run()
val responseOutSub = responseOut.expectSubscription()
(requestIn, responseOut, responseOutSub, hcp)
Expand Down
Expand Up @@ -124,7 +124,7 @@ class HttpsProxyGraphStageSpec extends AkkaSpecWithMaterializer {

flowOutProbe.sendNext(ByteString("HTTP/1.0 501 Some Error\r\n\r\n"))

sink.expectError match {
sink.expectError() match {
case _: ProxyConnectionFailedException =>
case e =>
fail(s"should be ProxyConnectionFailedException, caught ${e.getClass.getName} instead")
Expand Down
Expand Up @@ -279,7 +279,7 @@ class LowLevelOutgoingConnectionSpec extends AkkaSpecWithMaterializer with Insid

inside(expectResponse()) {
case HttpResponse(StatusCodes.OK, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
// but only one consumed by server
data.take(1).to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
Expand Down
Expand Up @@ -49,7 +49,7 @@ class PrepareResponseSpec extends AkkaSpec {
implicit val mat = ActorMaterializer()

val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]()
val responseProbe = TestSubscriber.manualProbe[HttpResponse]
val responseProbe = TestSubscriber.manualProbe[HttpResponse]()

Source.fromPublisher(inProbe)
.via(new PrepareResponse(parserSettings))
Expand Down Expand Up @@ -94,7 +94,7 @@ class PrepareResponseSpec extends AkkaSpec {
implicit val mat = ActorMaterializer()

val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]()
val responseProbe = TestSubscriber.manualProbe[HttpResponse]
val responseProbe = TestSubscriber.manualProbe[HttpResponse]()

Source.fromPublisher(inProbe)
.via(new PrepareResponse(parserSettings))
Expand Down Expand Up @@ -130,7 +130,7 @@ class PrepareResponseSpec extends AkkaSpec {
implicit val mat = ActorMaterializer()

val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]()
val responseProbe = TestSubscriber.manualProbe[HttpResponse]
val responseProbe = TestSubscriber.manualProbe[HttpResponse]()

Source.fromPublisher(inProbe)
.via(new PrepareResponse(parserSettings))
Expand Down Expand Up @@ -171,7 +171,7 @@ class PrepareResponseSpec extends AkkaSpec {
implicit val mat = ActorMaterializer()

val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]()
val responseProbe = TestSubscriber.manualProbe[HttpResponse]
val responseProbe = TestSubscriber.manualProbe[HttpResponse]()

Source.fromPublisher(inProbe)
.via(new PrepareResponse(parserSettings))
Expand Down Expand Up @@ -199,7 +199,7 @@ class PrepareResponseSpec extends AkkaSpec {
implicit val mat = ActorMaterializer()

val inProbe = TestPublisher.manualProbe[ParserOutput.ResponseOutput]()
val responseProbe = TestSubscriber.manualProbe[HttpResponse]
val responseProbe = TestSubscriber.manualProbe[HttpResponse]()

Source.fromPublisher(inProbe)
.via(new PrepareResponse(parserSettings))
Expand Down
Expand Up @@ -28,7 +28,7 @@ class ResponseParsingMergeSpec extends AkkaSpec {

val inBypassProbe = TestPublisher.manualProbe[OutgoingConnectionBlueprint.BypassData]()
val inSessionBytesProbe = TestPublisher.manualProbe[SessionBytes]()
val responseProbe = TestSubscriber.manualProbe[List[ParserOutput.ResponseOutput]]
val responseProbe = TestSubscriber.manualProbe[List[ParserOutput.ResponseOutput]]()

val responseParsingMerge: ResponseParsingMerge = {
val rootParser = new HttpResponseParser(parserSettings, HttpHeaderParser(parserSettings, log))
Expand Down
Expand Up @@ -31,7 +31,7 @@ class SlotStateSpec extends AkkaSpec {
RequestContext(
HttpRequest(
entity = HttpEntity(ContentTypes.`application/octet-stream`, Source.single(ByteString("test")))),
Promise[HttpResponse], 0
Promise[HttpResponse](), 0
)

"The new connection pool slot state machine" should {
Expand Down
Expand Up @@ -207,7 +207,7 @@ abstract class HttpHeaderParserSpec(mode: String, newLine: String) extends AkkaS
"continue parsing raw headers even if the overall cache value capacity is reached" in new TestSetup() {
val randomHeaders = Iterator.continually {
val name = nextRandomString(nextRandomAlphaNumChar _, nextRandomInt(4, 16))
val value = nextRandomString(() => nextRandomPrintableChar, nextRandomInt(4, 16))
val value = nextRandomString(() => nextRandomPrintableChar(), nextRandomInt(4, 16))
RawHeader(name, value)
}
randomHeaders.take(300).foldLeft(0) {
Expand Down Expand Up @@ -239,7 +239,7 @@ abstract class HttpHeaderParserSpec(mode: String, newLine: String) extends AkkaS

"continue parsing raw headers even if the header-specific cache capacity is reached" in new TestSetup() {
val randomHeaders = Iterator.continually {
val value = nextRandomString(() => nextRandomPrintableChar, nextRandomInt(4, 16))
val value = nextRandomString(() => nextRandomPrintableChar(), nextRandomInt(4, 16))
RawHeader("Fancy", value)
}
randomHeaders.take(20).foldLeft(0) {
Expand Down Expand Up @@ -311,7 +311,7 @@ abstract class HttpHeaderParserSpec(mode: String, newLine: String) extends AkkaS
accept.mediaRanges.head.getParams.size should be(numKeys)
}

BenchUtils.nanoRace(regular, colliding) should be < 3.0 // speed must be in same order of magnitude
BenchUtils.nanoRace(regular(), colliding()) should be < 3.0 // speed must be in same order of magnitude
}
}

Expand Down
Expand Up @@ -71,7 +71,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Default(_, 12, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ByteString]
val dataProbe = TestSubscriber.manualProbe[ByteString]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -121,7 +121,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -177,7 +177,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Default(_, 12, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ByteString]
val dataProbe = TestSubscriber.manualProbe[ByteString]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand All @@ -202,7 +202,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -255,7 +255,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Default(_, 12, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ByteString]
val dataProbe = TestSubscriber.manualProbe[ByteString]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -295,7 +295,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -334,7 +334,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Default(_, 12, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ByteString]
val dataProbe = TestSubscriber.manualProbe[ByteString]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand All @@ -358,7 +358,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -390,7 +390,7 @@ class HttpServerSpec extends AkkaSpec(

inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
// but only one consumed by server
data.take(1).to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
Expand Down Expand Up @@ -432,7 +432,7 @@ class HttpServerSpec extends AkkaSpec(
|abcdef""")
inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Default(_, 12, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ByteString]
val dataProbe = TestSubscriber.manualProbe[ByteString]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand All @@ -454,7 +454,7 @@ class HttpServerSpec extends AkkaSpec(
|""")
inside(expectRequest()) {
case HttpRequest(POST, _, _, HttpEntity.Chunked(_, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val sub = dataProbe.expectSubscription()
sub.request(10)
Expand Down Expand Up @@ -617,7 +617,7 @@ class HttpServerSpec extends AkkaSpec(
|""")
inside(expectRequest()) {
case HttpRequest(POST, _, _, Default(ContentType(`application/octet-stream`, None), 16, data), _) =>
val dataProbe = TestSubscriber.manualProbe[ByteString]
val dataProbe = TestSubscriber.manualProbe[ByteString]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val dataSub = dataProbe.expectSubscription()
netOut.expectNoBytes(50.millis.dilated)
Expand Down Expand Up @@ -657,7 +657,7 @@ class HttpServerSpec extends AkkaSpec(
|""")
inside(expectRequest()) {
case HttpRequest(POST, _, _, Chunked(ContentType(`application/octet-stream`, None), data), _) =>
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]
val dataProbe = TestSubscriber.manualProbe[ChunkStreamPart]()
data.to(Sink.fromSubscriber(dataProbe)).run()
val dataSub = dataProbe.expectSubscription()
netOut.expectNoBytes(50.millis.dilated)
Expand Down
Expand Up @@ -23,7 +23,7 @@ abstract class HttpServerTestSetupBase {
implicit def system: ActorSystem
implicit def materializer: Materializer

val requests = TestSubscriber.probe[HttpRequest]
val requests = TestSubscriber.probe[HttpRequest]()
val responses = TestPublisher.probe[HttpResponse]()

def settings = ServerSettings(system)
Expand Down
Expand Up @@ -983,7 +983,7 @@ class MessageSpec extends AkkaSpecWithMaterializer with Eventually {

val netIn = TestPublisher.probe[ByteString]()
val netOut = ByteStringSinkProbe()
val messageIn = TestSubscriber.probe[Message]
val messageIn = TestSubscriber.probe[Message]()
val messageOut = TestPublisher.probe[Message]()
val messageHandler: Flow[Message, Message, NotUsed] =
Flow.fromSinkAndSource(
Expand Down
Expand Up @@ -78,7 +78,7 @@ class WebSocketIntegrationSpec extends AkkaSpec("akka.stream.materializer.debug.
FlowShape(Inlet("completeOnlySwitch.in"), Outlet("completeOnlySwitch.out"))

override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Promise[Done]) = {
val promise = Promise[Done]
val promise = Promise[Done]()

val logic = new GraphStageLogic(shape) with InHandler with OutHandler {
override def onPush(): Unit = push(shape.out, grab(shape.in))
Expand Down Expand Up @@ -195,7 +195,7 @@ class WebSocketIntegrationSpec extends AkkaSpec("akka.stream.materializer.debug.
}

"terminate the handler flow with an error when the connection is aborted" in Utils.assertAllStagesStopped {
val handlerTermination = Promise[Done]
val handlerTermination = Promise[Done]()

val handler = Flow[Message]
.watchTermination()(Keep.right)
Expand Down
Expand Up @@ -814,7 +814,7 @@ Host: example.com

def handler(request: HttpRequest): Future[HttpResponse] = {
request.entity.dataBytes.runWith(dataProbe.sink)
Promise[HttpResponse].future // just let it hanging until idle timeout triggers
Promise[HttpResponse]().future // just let it hanging until idle timeout triggers
}

val settings = ServerSettings(system).mapTimeouts(_.withIdleTimeout(1.second))
Expand Down Expand Up @@ -846,7 +846,7 @@ Host: example.com
val (connSource, binding: Future[ServerBinding]) = {
val settings = configOverrides.toOption.fold(ServerSettings(system))(ServerSettings(_))
val connections = Http().bind(hostname, port, settings = settings)
val probe = TestSubscriber.manualProbe[Http.IncomingConnection]
val probe = TestSubscriber.manualProbe[Http.IncomingConnection]()
val binding = connections.to(Sink.fromSubscriber(probe)).run()
(probe, binding)
}
Expand Down
Expand Up @@ -109,7 +109,7 @@ class GracefulTerminationSpec
"fail close delimited response streams" ignore new TestSetup {
val clientSystem = ActorSystem("client")
val r1 =
Http()(clientSystem).singleRequest(nextRequest, connectionContext = clientConnectionContext, settings = basePoolSettings)
Http()(clientSystem).singleRequest(nextRequest(), connectionContext = clientConnectionContext, settings = basePoolSettings)

// reply with an infinite entity stream
val chunks = Source
Expand Down
Expand Up @@ -155,7 +155,7 @@ class HttpEntitySpec extends AkkaSpecWithMaterializer {
}
"Chunked with LastChunk with trailer header keep header chunk" in {
val entity = Chunked(tpe, source(Chunk(abc), Chunk(fgh), Chunk(ijk), LastChunk("", RawHeader("Foo", "pip apo") :: Nil)))
val transformed = entity.transformDataBytes(duplicateBytesTransformer())
val transformed = entity.transformDataBytes(duplicateBytesTransformer)
val parts = transformed.chunks.runWith(Sink.seq).awaitResult(100.millis)

parts.map(_.data).reduce(_ ++ _) shouldEqual doubleChars("abcfghijk") ++ trailer
Expand Down Expand Up @@ -281,7 +281,7 @@ class HttpEntitySpec extends AkkaSpecWithMaterializer {
strict.toString + " == " + expectedRendering)
}

def duplicateBytesTransformer(): Flow[ByteString, ByteString, NotUsed] =
def duplicateBytesTransformer: Flow[ByteString, ByteString, NotUsed] =
Flow[ByteString].via(StreamUtils.byteStringTransformer(doubleChars, () => trailer))

def trailer: ByteString = ByteString("--dup")
Expand Down

0 comments on commit d971d23

Please sign in to comment.