=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:
Roland Kuhn 2015-09-25 12:51:55 +02:00
parent ae83053a64
commit 68ba0643d6
58 changed files with 160 additions and 132 deletions

View file

@ -23,13 +23,13 @@ object MyRejectionHandler {
complete(HttpResponse(BadRequest, entity = "No cookies, no service!!!"))
}
.handle { case AuthorizationFailedRejection
complete(Forbidden, "You're out of your depth!")
complete((Forbidden, "You're out of your depth!"))
}
.handleAll[MethodRejection] { methodRejections
val names = methodRejections.map(_.supported.name)
complete(MethodNotAllowed, s"Can't do that! Supported: ${names mkString " or "}!")
complete((MethodNotAllowed, s"Can't do that! Supported: ${names mkString " or "}!"))
}
.handleNotFound { complete(NotFound, "Not here!") }
.handleNotFound { complete((NotFound, "Not here!")) }
.result()
object MyApp extends App {

View file

@ -20,7 +20,7 @@ class DebuggingDirectivesExamplesSpec extends RoutingSpec {
DebuggingDirectives.logRequest("get-user")
// marks with "get-user", log with info level, HttpRequest.toString
DebuggingDirectives.logRequest("get-user", Logging.InfoLevel)
DebuggingDirectives.logRequest(("get-user", Logging.InfoLevel))
// logs just the request method at debug level
def requestMethod(req: HttpRequest): String = req.method.toString
@ -46,7 +46,7 @@ class DebuggingDirectivesExamplesSpec extends RoutingSpec {
DebuggingDirectives.logRequestResult("get-user")
// marks with "get-user", log with info level, HttpRequest.toString, HttpResponse.toString
DebuggingDirectives.logRequestResult("get-user", Logging.InfoLevel)
DebuggingDirectives.logRequestResult(("get-user", Logging.InfoLevel))
// logs just the request method and response status at info level
def requestMethodAndResponseStatusAsInfo(req: HttpRequest): Any => Option[LogEntry] = {
@ -72,7 +72,7 @@ class DebuggingDirectivesExamplesSpec extends RoutingSpec {
DebuggingDirectives.logResult("get-user")
// marks with "get-user", log with info level, HttpResponse.toString
DebuggingDirectives.logResult("get-user", Logging.InfoLevel)
DebuggingDirectives.logResult(("get-user", Logging.InfoLevel))
// logs just the response status at debug level
def responseStatus(res: Any): String = res match {

View file

@ -11,7 +11,7 @@ import akka.http.scaladsl.server._
class ExecutionDirectivesExamplesSpec extends RoutingSpec {
"handleExceptions" in {
val divByZeroHandler = ExceptionHandler {
case _: ArithmeticException => complete(StatusCodes.BadRequest, "You've got your arithmetic wrong, fool!")
case _: ArithmeticException => complete((StatusCodes.BadRequest, "You've got your arithmetic wrong, fool!"))
}
val route =
path("divide" / IntNumber / IntNumber) { (a, b) =>
@ -30,7 +30,7 @@ class ExecutionDirectivesExamplesSpec extends RoutingSpec {
}
"handleRejections" in {
val totallyMissingHandler = RejectionHandler.newBuilder()
.handleNotFound { complete(StatusCodes.NotFound, "Oh man, what you are looking for is long gone.") }
.handleNotFound { complete((StatusCodes.NotFound, "Oh man, what you are looking for is long gone.")) }
.result()
val route =
pathPrefix("handled") {

View file

@ -23,7 +23,7 @@ class FutureDirectivesExamplesSpec extends RoutingSpec {
implicit val myExceptionHandler =
ExceptionHandler {
case TestException => ctx =>
ctx.complete(InternalServerError, "Unsuccessful future!")
ctx.complete((InternalServerError, "Unsuccessful future!"))
}
val resourceActor = system.actorOf(Props(new Actor {
@ -40,7 +40,7 @@ class FutureDirectivesExamplesSpec extends RoutingSpec {
path("divide" / IntNumber / IntNumber) { (a, b) =>
onComplete(divide(a, b)) {
case Success(value) => complete(s"The result was $value")
case Failure(ex) => complete(InternalServerError, s"An error occurred: ${ex.getMessage}")
case Failure(ex) => complete((InternalServerError, s"An error occurred: ${ex.getMessage}"))
}
}

View file

@ -16,7 +16,7 @@ class PathDirectivesExamplesSpec extends RoutingSpec {
//# path-dsl
// matches /foo/
path("foo" /)
path("foo"./)
// matches e.g. /foo/123 and extracts "123" as a String
path("foo" / """\d+""".r)

View file

@ -16,7 +16,7 @@ class RouteDirectivesExamplesSpec extends RoutingSpec {
complete(HttpResponse(entity = "foo"))
} ~
path("b") {
complete(StatusCodes.Created, "bar")
complete((StatusCodes.Created, "bar"))
} ~
(path("c") & complete("baz")) // `&` also works with `complete` as the 2nd argument

View file

@ -199,7 +199,7 @@ class FlowDocSpec extends AkkaSpec {
val (promise, cancellable, future) = r11.run()
// Type inference works as expected
promise.success(0)
promise.success(())
cancellable.cancel()
future.map(_ + 3)

View file

@ -141,8 +141,9 @@ class FlowGraphDocSpec extends AkkaSpec {
outlets: immutable.Seq[Outlet[_]]) = {
assert(inlets.size == this.inlets.size)
assert(outlets.size == this.outlets.size)
// This is why order matters when overriding inlets and outlets
PriorityWorkerPoolShape(inlets(0), inlets(1), outlets(0))
// This is why order matters when overriding inlets and outlets.
// The "[Nothing, Any]" is equivalent to casting the Inlets/Outlets.
PriorityWorkerPoolShape[Nothing, Any](inlets(0), inlets(1), outlets(0))
}
}
//#flow-graph-components-shape

View file

@ -32,6 +32,7 @@ class StreamFileDocSpec extends AkkaSpec(UnboundedMailboxConfig) {
//#file-source
import akka.stream.io._
//#file-source
Thread.sleep(0) // needs a statement here for valid syntax and to avoid "unused" warnings
}
{