=str,htp clean up build warnings
- explicitly provide Unit values and place parens around tuple creation - remove structural type usage in TestUtils - fix Java double-casts - use unused Java values by asserting their non-nullness - work around inability to place case class in trait (scripted test) The remaining warnings about using private types in public methods are bogus as reported in https://issues.scala-lang.org/browse/SI-9490.
This commit is contained in:
parent
ae83053a64
commit
68ba0643d6
58 changed files with 160 additions and 132 deletions
|
|
@ -23,17 +23,17 @@ public abstract class Util {
|
|||
// needed to provide covariant conversions that the Java interfaces don't provide automatically.
|
||||
// The alternative would be having to cast around everywhere instead of doing it here in a central place.
|
||||
public static <U, T extends U> Option<U> convertOption(scala.Option<T> o) {
|
||||
return (Option<U>)(Option) akka.japi.Option.fromScalaOption(o);
|
||||
return (Option<U>)(Object) akka.japi.Option.fromScalaOption(o);
|
||||
}
|
||||
@SuppressWarnings("unchecked") // no support for covariance of Publisher in Java
|
||||
// needed to provide covariant conversions that the Java interfaces don't provide automatically.
|
||||
// The alternative would be having to cast around everywhere instead of doing it here in a central place.
|
||||
public static <U, T extends U> Source<U, scala.Unit> convertPublisher(Source<T, scala.Unit> p) {
|
||||
return (Source<U, scala.Unit>)(Source) p;
|
||||
return (Source<U, scala.Unit>)(Object) p;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, U extends T> Source<U, scala.Unit> upcastSource(Source<T, scala.Unit> p) {
|
||||
return (Source<U, scala.Unit>)(Source) p;
|
||||
return (Source<U, scala.Unit>)(Object) p;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static scala.collection.immutable.Map<String, String> convertMapToScala(Map<String, String> map) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public abstract class ContentRange {
|
|||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ContentRange create(long first, long last, Option<Long> instanceLength) {
|
||||
return ContentRange$.MODULE$.apply(first, last, ((Option<Object>) (Option) instanceLength).asScala());
|
||||
return ContentRange$.MODULE$.apply(first, last, ((Option<Object>) (Object) instanceLength).asScala());
|
||||
}
|
||||
public static ContentRange createUnsatisfiable(long length) {
|
||||
return new akka.http.scaladsl.model.ContentRange.Unsatisfiable(length);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
import akka.http.scaladsl.model.headers.HttpChallenge$;
|
||||
import akka.http.impl.util.Util;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public abstract class HttpCookie {
|
|||
return new akka.http.scaladsl.model.headers.HttpCookie(
|
||||
name, value,
|
||||
Util.<DateTime, akka.http.scaladsl.model.DateTime>convertOptionToScala(expires),
|
||||
((Option<Object>) (Option) maxAge).asScala(),
|
||||
((Option<Object>) (Object) maxAge).asScala(),
|
||||
domain.asScala(),
|
||||
path.asScala(),
|
||||
secure,
|
||||
|
|
|
|||
|
|
@ -4,10 +4,6 @@
|
|||
|
||||
package akka.http.javadsl.model.headers;
|
||||
|
||||
import akka.http.javadsl.model.MediaType;
|
||||
import akka.http.javadsl.model.Uri;
|
||||
import akka.http.impl.util.Util;
|
||||
|
||||
public abstract class LinkParam {
|
||||
public abstract String key();
|
||||
public abstract Object value();
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ private[http] object OutgoingConnectionBlueprint {
|
|||
case (ctx, `terminationBackchannelInput`) ⇒
|
||||
ctx.finish()
|
||||
SameState
|
||||
case (_, _) ⇒ SameState
|
||||
},
|
||||
onUpstreamFailure = defaultCompletionHandling.onUpstreamFailure)
|
||||
}
|
||||
|
|
@ -220,6 +221,7 @@ private[http] object OutgoingConnectionBlueprint {
|
|||
ctx.fail(new ResponseParsingError(parser.onPull().asInstanceOf[ErrorOutput]))
|
||||
}
|
||||
SameState
|
||||
case (_, _) ⇒ SameState
|
||||
},
|
||||
onUpstreamFailure = defaultCompletionHandling.onUpstreamFailure)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,10 +204,14 @@ private[http] object HttpServerBluePrint {
|
|||
}
|
||||
|
||||
case (ctx, _, OneHundredContinue) ⇒
|
||||
assert(requestStart.expect100ContinueResponsePending)
|
||||
require(requestStart.expect100ContinueResponsePending)
|
||||
ctx.emit(ResponseRenderingContext(HttpResponse(StatusCodes.Continue)))
|
||||
requestStart = requestStart.copy(expect100ContinueResponsePending = false)
|
||||
SameState
|
||||
|
||||
case (ctx, _, msg) ⇒
|
||||
ctx.fail(new IllegalStateException(s"unexpected message of type [${msg.getClass}], expecting only HttpResponse or OneHundredContinue"))
|
||||
SameState
|
||||
}
|
||||
|
||||
val waitingForApplicationResponseCompletionHandling = CompletionHandling(
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ private[http] class FrameEventParser extends ByteStringParserStage[FrameEvent] {
|
|||
remaining -= elem.size
|
||||
ctx.push(FrameData(elem, lastPart = false))
|
||||
} else {
|
||||
assert(remaining <= Int.MaxValue) // safe because, remaining <= elem.size <= Int.MaxValue
|
||||
require(remaining <= Int.MaxValue) // safe because, remaining <= elem.size <= Int.MaxValue
|
||||
val frameData = elem.take(remaining.toInt)
|
||||
val remainingData = elem.drop(remaining.toInt)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,13 @@ private[http] class FrameEventRenderer extends StatefulStage[FrameEvent, ByteStr
|
|||
object Idle extends State {
|
||||
def onPush(elem: FrameEvent, ctx: Context[ByteString]): SyncDirective = elem match {
|
||||
case start @ FrameStart(header, data) ⇒
|
||||
assert(header.length >= data.size)
|
||||
require(header.length >= data.size)
|
||||
if (!start.lastPart && header.length > 0) become(renderData(header.length - data.length, this))
|
||||
|
||||
ctx.push(renderStart(start))
|
||||
|
||||
case f: FrameData ⇒
|
||||
ctx.fail(new IllegalStateException("unexpected FrameData (need FrameStart first)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +46,9 @@ private[http] class FrameEventRenderer extends StatefulStage[FrameEvent, ByteStr
|
|||
remaining -= data.size
|
||||
ctx.push(data)
|
||||
}
|
||||
|
||||
case f: FrameStart ⇒
|
||||
ctx.fail(new IllegalStateException("unexpected FrameStart (need more FrameData first)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,10 +106,11 @@ private[http] object FrameHandler {
|
|||
val closeCode = FrameEventParser.parseCloseCode(data)
|
||||
emit(Iterator(Left(PeerClosed(closeCode)), Right(PeerClosed(closeCode))), ctx, WaitForPeerTcpClose)
|
||||
case Opcode.Other(o) ⇒ closeWithCode(Protocol.CloseCodes.ProtocolError, "Unsupported opcode")
|
||||
case other ⇒ ctx.fail(new IllegalStateException(s"unexpected message of type [${other.getClass.getName}] when expecting ControlFrame"))
|
||||
}
|
||||
}
|
||||
private def collectControlFrame(start: FrameStart, nextState: State)(implicit ctx: Ctx): SyncDirective = {
|
||||
assert(!start.isFullMessage)
|
||||
require(!start.isFullMessage)
|
||||
become(new CollectingControlFrame(start.header.opcode, start.data, nextState))
|
||||
ctx.pull()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ private[http] object Masking {
|
|||
become(new Running(mask))
|
||||
current.onPush(start.copy(header = setNewMask(header, mask)), ctx)
|
||||
}
|
||||
case _: FrameData ⇒
|
||||
ctx.fail(new IllegalStateException("unexpected FrameData (need FrameStart first)"))
|
||||
}
|
||||
}
|
||||
class Running(initialMask: Int) extends State {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ private[http] class Utf8Encoder extends PushStage[String, ByteString] {
|
|||
val builder = new ByteStringBuilder
|
||||
|
||||
def b(v: Int): Unit = {
|
||||
assert((v & 0xff) == v)
|
||||
builder += v.toByte
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ package object util {
|
|||
new EnhancedInetSocketAddress(address)
|
||||
private[http] implicit def enhanceByteStrings(byteStrings: TraversableOnce[ByteString]): EnhancedByteStringTraversableOnce =
|
||||
new EnhancedByteStringTraversableOnce(byteStrings)
|
||||
private[http] implicit def enhanceByteStrings[Mat](byteStrings: Source[ByteString, Mat]): EnhancedByteStringSource[Mat] =
|
||||
private[http] implicit def enhanceByteStringsMat[Mat](byteStrings: Source[ByteString, Mat]): EnhancedByteStringSource[Mat] =
|
||||
new EnhancedByteStringSource(byteStrings)
|
||||
|
||||
private[http] def headAndTailFlow[T]: Flow[Source[T, Any], (T, Source[T, Unit]), Unit] =
|
||||
|
|
|
|||
|
|
@ -209,8 +209,8 @@ class ConnectionPoolSpec extends AkkaSpec("""
|
|||
val PoolGateway.Running(_, shutdownStartedPromise, shutdownCompletedPromise) = gateway.currentState
|
||||
shutdownStartedPromise.isCompleted shouldEqual false
|
||||
shutdownCompletedPromise.isCompleted shouldEqual false
|
||||
Await.result(shutdownStartedPromise.future, 1500.millis) shouldEqual () // verify shutdown start (after idle)
|
||||
Await.result(shutdownCompletedPromise.future, 1500.millis) shouldEqual () // verify shutdown completed
|
||||
Await.result(shutdownStartedPromise.future, 1500.millis) // verify shutdown start (after idle)
|
||||
Await.result(shutdownCompletedPromise.future, 1500.millis) // verify shutdown completed
|
||||
}
|
||||
|
||||
"transparently restart after idle shutdown" in new TestSetup() {
|
||||
|
|
@ -218,7 +218,7 @@ class ConnectionPoolSpec extends AkkaSpec("""
|
|||
|
||||
val gateway = Await.result(hcp.gatewayFuture, 500.millis)
|
||||
val PoolGateway.Running(_, _, shutdownCompletedPromise) = gateway.currentState
|
||||
Await.result(shutdownCompletedPromise.future, 1500.millis) shouldEqual () // verify shutdown completed
|
||||
Await.result(shutdownCompletedPromise.future, 1500.millis) // verify shutdown completed
|
||||
|
||||
requestIn.sendNext(HttpRequest(uri = "/") -> 42)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue