diff --git a/docs/src/test/java/docs/http/javadsl/CustomMediaTypesExampleTest.java b/docs/src/test/java/docs/http/javadsl/CustomMediaTypesExampleTest.java index 2c16bc922..6f0049b68 100644 --- a/docs/src/test/java/docs/http/javadsl/CustomMediaTypesExampleTest.java +++ b/docs/src/test/java/docs/http/javadsl/CustomMediaTypesExampleTest.java @@ -14,7 +14,6 @@ package docs.http.javadsl; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.model.HttpCharsets; diff --git a/docs/src/test/java/docs/http/javadsl/CustomStatusCodesExampleTest.java b/docs/src/test/java/docs/http/javadsl/CustomStatusCodesExampleTest.java index 65d883faf..29d9f84f3 100644 --- a/docs/src/test/java/docs/http/javadsl/CustomStatusCodesExampleTest.java +++ b/docs/src/test/java/docs/http/javadsl/CustomStatusCodesExampleTest.java @@ -14,7 +14,6 @@ package docs.http.javadsl; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.ConnectionContext; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; diff --git a/docs/src/test/java/docs/http/javadsl/HttpClientExampleDocTest.java b/docs/src/test/java/docs/http/javadsl/HttpClientExampleDocTest.java index da6dd6cdd..34f619d33 100644 --- a/docs/src/test/java/docs/http/javadsl/HttpClientExampleDocTest.java +++ b/docs/src/test/java/docs/http/javadsl/HttpClientExampleDocTest.java @@ -16,33 +16,34 @@ import org.apache.pekko.Done; import org.apache.pekko.NotUsed; import org.apache.pekko.actor.*; +import org.apache.pekko.http.javadsl.ClientTransport; +import org.apache.pekko.http.javadsl.Http; +import org.apache.pekko.http.javadsl.OutgoingConnection; import org.apache.pekko.http.javadsl.model.headers.HttpCredentials; import org.apache.pekko.http.javadsl.model.headers.SetCookie; -import org.apache.pekko.util.ByteString; -import scala.concurrent.ExecutionContextExecutor; -import org.apache.pekko.stream.javadsl.*; -import org.apache.pekko.http.javadsl.ClientTransport; import org.apache.pekko.http.javadsl.settings.ClientConnectionSettings; import org.apache.pekko.http.javadsl.settings.ConnectionPoolSettings; -import org.apache.pekko.http.javadsl.Http; -import org.apache.pekko.http.javadsl.OutgoingConnection; - -import static org.apache.pekko.http.javadsl.ConnectHttp.toHost; -import static org.apache.pekko.util.ByteString.emptyByteString; +import org.apache.pekko.stream.javadsl.*; +import org.apache.pekko.util.ByteString; import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletionStage; +import scala.concurrent.ExecutionContextExecutor; + +import static org.apache.pekko.util.ByteString.emptyByteString; + // #manual-entity-consume-example-1 import java.io.File; - import java.util.concurrent.TimeUnit; import java.util.function.Function; + +import scala.concurrent.duration.FiniteDuration; + import org.apache.pekko.stream.javadsl.Framing; import org.apache.pekko.http.javadsl.model.*; -import scala.concurrent.duration.FiniteDuration; // #manual-entity-consume-example-1 // #single-request-in-actor-example diff --git a/docs/src/test/java/docs/http/javadsl/HttpServerActorInteractionExample.java b/docs/src/test/java/docs/http/javadsl/HttpServerActorInteractionExample.java index 836a4877c..c1ed13c87 100644 --- a/docs/src/test/java/docs/http/javadsl/HttpServerActorInteractionExample.java +++ b/docs/src/test/java/docs/http/javadsl/HttpServerActorInteractionExample.java @@ -23,7 +23,6 @@ import org.apache.pekko.actor.typed.javadsl.ActorContext; import org.apache.pekko.actor.typed.javadsl.Behaviors; import org.apache.pekko.actor.typed.javadsl.Receive; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson; diff --git a/docs/src/test/java/docs/http/javadsl/HttpServerLowLevelExample.java b/docs/src/test/java/docs/http/javadsl/HttpServerLowLevelExample.java index d5989200b..cf8e9f34b 100644 --- a/docs/src/test/java/docs/http/javadsl/HttpServerLowLevelExample.java +++ b/docs/src/test/java/docs/http/javadsl/HttpServerLowLevelExample.java @@ -16,7 +16,6 @@ // #low-level-server-example import org.apache.pekko.actor.typed.ActorSystem; import org.apache.pekko.actor.typed.javadsl.Behaviors; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.model.ContentTypes; diff --git a/docs/src/test/java/docs/http/javadsl/HttpServerStreamRandomNumbersTest.java b/docs/src/test/java/docs/http/javadsl/HttpServerStreamRandomNumbersTest.java index a73008623..229a89ba6 100644 --- a/docs/src/test/java/docs/http/javadsl/HttpServerStreamRandomNumbersTest.java +++ b/docs/src/test/java/docs/http/javadsl/HttpServerStreamRandomNumbersTest.java @@ -17,7 +17,6 @@ import org.apache.pekko.NotUsed; import org.apache.pekko.actor.typed.ActorSystem; import org.apache.pekko.actor.typed.javadsl.Behaviors; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.model.*; diff --git a/docs/src/test/java/docs/http/javadsl/HttpsExamplesDocTest.java b/docs/src/test/java/docs/http/javadsl/HttpsExamplesDocTest.java index 49148c5f8..945f96428 100644 --- a/docs/src/test/java/docs/http/javadsl/HttpsExamplesDocTest.java +++ b/docs/src/test/java/docs/http/javadsl/HttpsExamplesDocTest.java @@ -14,7 +14,6 @@ package docs.http.javadsl; import org.apache.pekko.actor.ActorSystem; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.ConnectionContext; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.HttpsConnectionContext; diff --git a/docs/src/test/java/docs/http/javadsl/JacksonExampleTest.java b/docs/src/test/java/docs/http/javadsl/JacksonExampleTest.java index 8230cd794..25c01c9c3 100644 --- a/docs/src/test/java/docs/http/javadsl/JacksonExampleTest.java +++ b/docs/src/test/java/docs/http/javadsl/JacksonExampleTest.java @@ -17,7 +17,6 @@ import org.apache.pekko.NotUsed; import org.apache.pekko.actor.typed.ActorSystem; import org.apache.pekko.actor.typed.javadsl.Behaviors; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson; diff --git a/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java b/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java index b662a168a..8ac0670cd 100644 --- a/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java +++ b/docs/src/test/java/docs/http/javadsl/server/HttpServerExampleDocTest.java @@ -51,7 +51,7 @@ public static void bindingExample() throws Exception { Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = - Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); + Http.get(system).newServerAt("localhost", 8080).connectionSource(); CompletionStage serverBindingFuture = serverSource @@ -73,7 +73,7 @@ public static void bindingFailureExample() throws Exception { Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = - Http.get(system).bind(ConnectHttp.toHost("localhost", 80)); + Http.get(system).newServerAt("localhost", 80).connectionSource(); CompletionStage serverBindingFuture = serverSource @@ -101,7 +101,7 @@ public static void connectionSourceFailureExample() throws Exception { Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = - Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); + Http.get(system).newServerAt("localhost", 8080).connectionSource(); Flow failureDetection = Flow.of(IncomingConnection.class) @@ -137,7 +137,7 @@ public static void connectionStreamFailureExample() throws Exception { Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = - Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); + Http.get(system).newServerAt("localhost", 8080).connectionSource(); Flow failureDetection = Flow.of(HttpRequest.class) @@ -186,7 +186,7 @@ public static void fullServerExample() throws Exception { final Materializer materializer = Materializer.createMaterializer(system); Source> serverSource = - Http.get(system).bind(ConnectHttp.toHost("localhost", 8080)); + Http.get(system).newServerAt("localhost", 8080).connectionSource(); // #request-handler final Function requestHandler = @@ -379,10 +379,8 @@ public static void gracefulTerminationExample() throws Exception { CompletionStage binding = Http.get(system) - .bindAndHandle( - Directives.complete("Hello world!").flow(system, materializer), - ConnectHttp.toHost("localhost", 8080), - materializer); + .newServerAt("localhost", 8080) + .bindFlow(Directives.complete("Hello world!").flow(system, materializer)); ServerBinding serverBinding = binding.toCompletableFuture().get(3, TimeUnit.SECONDS); diff --git a/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java b/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java index ae52b8eec..8ee24fe58 100644 --- a/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/PekkoHttp1020MigrationExample.java @@ -14,27 +14,13 @@ package docs.http.javadsl.server; import org.apache.pekko.actor.typed.javadsl.Behaviors; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import static org.apache.pekko.http.javadsl.server.Directives.*; import org.apache.pekko.http.javadsl.server.Route; import org.apache.pekko.stream.Materializer; -@SuppressWarnings("deprecation") public class PekkoHttp1020MigrationExample { public static void main(String[] args) { - { - // #old-binding - // only worked with classic actor system - org.apache.pekko.actor.ActorSystem system = - org.apache.pekko.actor.ActorSystem.create("TheSystem"); - Materializer mat = Materializer.createMaterializer(system); - Route route = get(() -> complete("Hello World!")); - Http.get(system) - .bindAndHandle(route.flow(system), ConnectHttp.toHost("localhost", 8080), mat); - // #old-binding - } - { // #new-binding // works with classic or typed actor system diff --git a/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java b/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java index 5455fa1c6..882405d7e 100644 --- a/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java +++ b/docs/src/test/java/docs/http/javadsl/server/WebSocketCoreExample.java @@ -24,7 +24,6 @@ import org.apache.pekko.NotUsed; import org.apache.pekko.http.impl.util.JavaMapping; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.ConnectionContext; import org.apache.pekko.http.javadsl.model.StatusCodes; import org.apache.pekko.http.javadsl.model.ws.WebSocketRequest; diff --git a/docs/src/test/java/docs/http/javadsl/server/directives/CustomHttpMethodExamplesTest.java b/docs/src/test/java/docs/http/javadsl/server/directives/CustomHttpMethodExamplesTest.java index 84fc3b662..ea72a286c 100644 --- a/docs/src/test/java/docs/http/javadsl/server/directives/CustomHttpMethodExamplesTest.java +++ b/docs/src/test/java/docs/http/javadsl/server/directives/CustomHttpMethodExamplesTest.java @@ -17,7 +17,6 @@ import org.apache.pekko.actor.ActorSystem; import org.apache.pekko.event.LoggingAdapter; import org.apache.pekko.event.NoLogging; -import org.apache.pekko.http.javadsl.ConnectHttp; import org.apache.pekko.http.javadsl.Http; import org.apache.pekko.http.javadsl.ServerBinding; import org.apache.pekko.http.javadsl.model.*; diff --git a/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala b/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala index ae9debd61..bc268edef 100644 --- a/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/server/PekkoHttp1020MigrationSpec.scala @@ -16,24 +16,10 @@ package docs.http.scaladsl.server import org.apache.pekko.actor.typed.scaladsl.Behaviors import org.apache.pekko.http.scaladsl.Http import org.apache.pekko.http.scaladsl.server.Route -import scala.annotation.nowarn -@nowarn("msg=is deprecated") class PekkoHttp1020MigrationSpec { import org.apache.pekko.http.scaladsl.server.Directives._ - { - // #old-binding - // only worked with classic actor system - implicit val system = org.apache.pekko.actor.ActorSystem("TheSystem") - val route: Route = - get { - complete("Hello world") - } - Http().bindAndHandle(route, "localhost", 8080) - // #old-binding - } - { // #new-binding // works with both classic and typed ActorSystem diff --git a/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes b/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes index d8a763c64..8b8e85c60 100644 --- a/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes +++ b/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes @@ -20,6 +20,8 @@ ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.impl. ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.impl.engine.server.HttpServerBluePrint#TimeoutAccessImpl.updateHandler") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.ConnectionContext.https") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.ConnectionContext.sslConfig") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bind") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bindAndHandle") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bindAndHandleAsync") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bindAndHandleSync") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.createServerHttpsContext") @@ -66,6 +68,10 @@ ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scalad ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpsConnectionContext.getClientAuth") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpsConnectionContext.getSslParameters") ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.http.scaladsl.HttpExt") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bind") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bind$*") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandle") +ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandle$*") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandleSync") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandleSync$*") ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandleAsync") diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala index 5a81eedfb..bd98c428f 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala @@ -224,7 +224,7 @@ private[http] final class Http2Ext(implicit val system: ActorSystem) engine.setUseClientMode(false) Http2AlpnSupport.enableForServer(engine, setChosenProtocol) } - @nowarn("msg=deprecated") // TODO find an alternative way to do this + // TODO find an alternative way to do this val tls = TLS(() => createEngine(), _ => Success(()), IgnoreComplete) ProtocolSwitch(_ => getChosenProtocol(), http1, http2).join( @@ -234,7 +234,7 @@ private[http] final class Http2Ext(implicit val system: ActorSystem) def outgoingConnection(host: String, port: Int, connectionContext: HttpsConnectionContext, clientConnectionSettings: ClientConnectionSettings, log: LoggingAdapter) : Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]] = { - @nowarn("msg=deprecated") // TODO find an alternative way to do this + // TODO find an alternative way to do this def createEngine(): SSLEngine = { val engine = connectionContext.engineCreator(Some((host, port))) engine.setUseClientMode(true) diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala index ffe8d5907..0af829131 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala @@ -35,7 +35,7 @@ import pekko.http.javadsl.settings.{ ClientConnectionSettings, ConnectionPoolSet import pekko.japi.Pair import pekko.stream.TLSProtocol._ import pekko.stream.Materializer -import pekko.stream.javadsl.{ BidiFlow, Flow, Source } +import pekko.stream.javadsl.{ BidiFlow, Flow } import pekko.stream.scaladsl.Keep import pekko.util.FutureConverters._ @@ -100,144 +100,6 @@ class Http(system: ExtendedActorSystem) extends pekko.actor.Extension { */ def newServerAt(interface: String, port: Int): ServerBuilder = ServerBuilder(interface, port, system) - /** - * Creates a [[pekko.stream.javadsl.Source]] of [[IncomingConnection]] instances which represents a prospective HTTP server binding - * on the given `endpoint`. - * - * If the given port is 0 the resulting source can be materialized several times. Each materialization will - * then be assigned a new local port by the operating system, which can then be retrieved by the materialized - * [[ServerBinding]]. - * - * If the given port is non-zero subsequent materialization attempts of the produced source will immediately - * fail, unless the first materialization has already been unbound. Unbinding can be triggered via the materialized - * [[ServerBinding]]. - * - * The server will be bound using HTTPS if the [[ConnectHttp]] object is configured with an [[HttpsConnectionContext]], - * or the [[defaultServerHttpContext]] has been configured to be an [[HttpsConnectionContext]]. - * - * @deprecated since Akka HTTP 10.2.0: Use Http.get(system).newServerAt(interface, port).connectionSource() instead - */ - @Deprecated - @deprecated("Use newServerAt instead", since = "Akka HTTP 10.2.0") - def bind(connect: ConnectHttp): Source[IncomingConnection, CompletionStage[ServerBinding]] = { - val connectionContext = connect.effectiveConnectionContext(defaultServerHttpContext).asScala - new Source(delegate.bind(connect.host, connect.port, connectionContext) - .map(new IncomingConnection(_)) - .mapMaterializedValue(_.map(new ServerBinding(_))(ec).asJava)) - } - - /** - * Creates a [[pekko.stream.javadsl.Source]] of [[IncomingConnection]] instances which represents a prospective HTTP server binding - * on the given `endpoint`. - * - * If the given port is 0 the resulting source can be materialized several times. Each materialization will - * then be assigned a new local port by the operating system, which can then be retrieved by the materialized - * [[ServerBinding]]. - * - * If the given port is non-zero subsequent materialization attempts of the produced source will immediately - * fail, unless the first materialization has already been unbound. Unbinding can be triggered via the materialized - * [[ServerBinding]]. - * - * The server will be bound using HTTPS if the [[ConnectHttp]] object is configured with an [[HttpsConnectionContext]], - * or the [[defaultServerHttpContext]] has been configured to be an [[HttpsConnectionContext]]. - * - * @deprecated since Akka HTTP 10.2.0: Use Http.get(system).newServerAt(interface, port).withSettings(settings).connectionSource() instead - */ - @Deprecated - @deprecated("Use newServerAt instead", since = "Akka HTTP 10.2.0") - def bind( - connect: ConnectHttp, - settings: ServerSettings): Source[IncomingConnection, CompletionStage[ServerBinding]] = { - val connectionContext = connect.effectiveConnectionContext(defaultServerHttpContext).asScala - new Source(delegate.bind(connect.host, connect.port, settings = settings.asScala, - connectionContext = connectionContext) - .map(new IncomingConnection(_)) - .mapMaterializedValue(_.map(new ServerBinding(_))(ec).asJava)) - } - - /** - * Creates a [[pekko.stream.javadsl.Source]] of [[IncomingConnection]] instances which represents a prospective HTTP server binding - * on the given `endpoint`. - * - * If the given port is 0 the resulting source can be materialized several times. Each materialization will - * then be assigned a new local port by the operating system, which can then be retrieved by the materialized - * [[ServerBinding]]. - * - * If the given port is non-zero subsequent materialization attempts of the produced source will immediately - * fail, unless the first materialization has already been unbound. Unbinding can be triggered via the materialized - * [[ServerBinding]]. - * - * The server will be bound using HTTPS if the [[ConnectHttp]] object is configured with an [[HttpsConnectionContext]], - * or the [[defaultServerHttpContext]] has been configured to be an [[HttpsConnectionContext]]. - * - * @deprecated since Akka HTTP 10.2.0: Use Http.get(system).newServerAt(interface, port).withSettings(settings).logTo(log).connectionSource() instead - */ - @Deprecated - @deprecated("Use newServerAt instead", since = "Akka HTTP 10.2.0") - def bind( - connect: ConnectHttp, - settings: ServerSettings, - log: LoggingAdapter): Source[IncomingConnection, CompletionStage[ServerBinding]] = { - val connectionContext = connect.effectiveConnectionContext(defaultServerHttpContext).asScala - new Source(delegate.bind(connect.host, connect.port, connectionContext, settings.asScala, log) - .map(new IncomingConnection(_)) - .mapMaterializedValue(_.map(new ServerBinding(_))(ec).asJava)) - } - - /** - * Convenience method which starts a new HTTP server at the given endpoint and uses the given `handler` - * [[pekko.stream.javadsl.Flow]] for processing all incoming connections. - * - * The number of concurrently accepted connections can be configured by overriding - * the `pekko.http.server.max-connections` setting. Please see the documentation in the reference.conf for more - * information about what kind of guarantees to expect. - * - * The server will be bound using HTTPS if the [[ConnectHttp]] object is configured with an [[HttpsConnectionContext]], - * or the [[defaultServerHttpContext]] has been configured to be an [[HttpsConnectionContext]]. - * - * @deprecated since Akka HTTP 10.2.0: Use Http.get(system).newServerAt(interface, port).bindFlow(handler) instead. - */ - @Deprecated - @deprecated("Use newServerAt instead", since = "Akka HTTP 10.2.0") - def bindAndHandle( - handler: Flow[HttpRequest, HttpResponse, _], - connect: ConnectHttp, - materializer: Materializer): CompletionStage[ServerBinding] = { - val connectionContext = connect.effectiveConnectionContext(defaultServerHttpContext).asScala - delegate.bindAndHandle( - handler.asInstanceOf[Flow[sm.HttpRequest, sm.HttpResponse, _]].asScala, - connect.host, connect.port, connectionContext)(materializer) - .map(new ServerBinding(_))(ec).asJava - } - - /** - * Convenience method which starts a new HTTP server at the given endpoint and uses the given `handler` - * [[pekko.stream.javadsl.Flow]] for processing all incoming connections. - * - * The number of concurrently accepted connections can be configured by overriding - * the `pekko.http.server.max-connections` setting. Please see the documentation in the reference.conf for more - * information about what kind of guarantees to expect. - * - * The server will be bound using HTTPS if the [[ConnectHttp]] object is configured with an [[HttpsConnectionContext]], - * or the [[defaultServerHttpContext]] has been configured to be an [[HttpsConnectionContext]]. - * - * @deprecated since Akka HTTP 10.2.0: Use Http.get(system).newServerAt(interface, port).withSettings(settings).logTo(log).bindFlow(handler) instead. - */ - @Deprecated - @deprecated("Use newServerAt instead", since = "Akka HTTP 10.2.0") - def bindAndHandle( - handler: Flow[HttpRequest, HttpResponse, _], - connect: ConnectHttp, - settings: ServerSettings, - log: LoggingAdapter, - materializer: Materializer): CompletionStage[ServerBinding] = { - val connectionContext = connect.effectiveConnectionContext(defaultServerHttpContext).asScala - delegate.bindAndHandle( - handler.asInstanceOf[Flow[sm.HttpRequest, sm.HttpResponse, _]].asScala, - connect.host, connect.port, connectionContext, settings.asScala, log)(materializer) - .map(new ServerBinding(_))(ec).asJava - } - /** * Constructs a client layer stage using the configured default [[pekko.http.javadsl.settings.ClientConnectionSettings]]. */ diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala index 853f7a1da..cd3893064 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala @@ -181,13 +181,10 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme * To configure additional settings for a server started using this method, * use the `pekko.http.server` config section or pass in a [[pekko.http.scaladsl.settings.ServerSettings]] explicitly. */ - @deprecated( - "Use Http().newServerAt(...)...connectionSource() to create a source that can be materialized to a binding.", - since = "Akka HTTP 10.2.0") - def bind(interface: String, port: Int = DefaultPortForProtocol, - connectionContext: ConnectionContext = defaultServerHttpContext, - settings: ServerSettings = ServerSettings(system), - log: LoggingAdapter = system.log): Source[Http.IncomingConnection, Future[ServerBinding]] = { + private[http] def bindImpl(interface: String, port: Int, + connectionContext: ConnectionContext, + settings: ServerSettings, + log: LoggingAdapter): Source[Http.IncomingConnection, Future[ServerBinding]] = { if (settings.previewServerSettings.enableHttp2) log.warning( s"Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1 for port [$port]") @@ -212,14 +209,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme } } - // forwarder to allow internal code to call deprecated method without warning - @nowarn("msg=deprecated") - private[http] def bindImpl(interface: String, port: Int, - connectionContext: ConnectionContext, - settings: ServerSettings, - log: LoggingAdapter): Source[Http.IncomingConnection, Future[ServerBinding]] = - bind(interface, port, connectionContext, settings, log) - /** * Convenience method which starts a new HTTP server at the given endpoint and uses the given `handler` * [[pekko.stream.scaladsl.Flow]] for processing all incoming connections. @@ -231,13 +220,12 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme * To configure additional settings for a server started using this method, * use the `pekko.http.server` config section or pass in a [[pekko.http.scaladsl.settings.ServerSettings]] explicitly. */ - @deprecated("Use Http().newServerAt(...)...bindFlow() to create server bindings.", since = "Akka HTTP 10.2.0") - def bindAndHandle( + private[http] def bindAndHandleImpl( handler: Flow[HttpRequest, HttpResponse, Any], - interface: String, port: Int = DefaultPortForProtocol, - connectionContext: ConnectionContext = defaultServerHttpContext, - settings: ServerSettings = ServerSettings(system), - log: LoggingAdapter = system.log)(implicit fm: Materializer = systemMaterializer): Future[ServerBinding] = { + interface: String, port: Int, + connectionContext: ConnectionContext, + settings: ServerSettings, + log: LoggingAdapter)(implicit fm: Materializer): Future[ServerBinding] = { if (settings.previewServerSettings.enableHttp2) log.warning( s"Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1 for port [$port].") @@ -292,19 +280,9 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme } // forwarder to allow internal code to call deprecated method without warning - @nowarn("msg=deprecated") - private[http] def bindAndHandleImpl( - handler: Flow[HttpRequest, HttpResponse, Any], - interface: String, port: Int, - connectionContext: ConnectionContext, - settings: ServerSettings, - log: LoggingAdapter)(implicit fm: Materializer): Future[ServerBinding] = - bindAndHandle(handler, interface, port, connectionContext, settings, log)(fm) - - private def bindAndHandleAsync( + private[http] def bindAndHandleAsyncImpl( handler: HttpRequest => Future[HttpResponse], - interface: String, - port: Int, + interface: String, port: Int, connectionContext: ConnectionContext, settings: ServerSettings, parallelism: Int, @@ -327,16 +305,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme } } - // forwarder to allow internal code to call deprecated method without warning - private[http] def bindAndHandleAsyncImpl( - handler: HttpRequest => Future[HttpResponse], - interface: String, port: Int, - connectionContext: ConnectionContext, - settings: ServerSettings, - parallelism: Int, - log: LoggingAdapter)(implicit fm: Materializer): Future[ServerBinding] = - bindAndHandleAsync(handler, interface, port, connectionContext, settings, parallelism, log)(fm) - type ServerLayer = Http.ServerLayer /** @@ -795,7 +763,7 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme private[http] def sslTlsServerStage(connectionContext: ConnectionContext) = sslTlsStage(connectionContext, Server, None) - @nowarn("msg=deprecated") // TODO find an alternative way to do this + // TODO find an alternative way to do this private def sslTlsStage(connectionContext: ConnectionContext, role: TLSRole, hostInfo: Option[(String, Int)]) = connectionContext match { case hctx: HttpsConnectionContext => diff --git a/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java b/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java index b83eaff4f..22a44473f 100644 --- a/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java +++ b/http-tests/src/test/java/org/apache/pekko/http/javadsl/HttpAPIsTest.java @@ -139,23 +139,4 @@ public void compileOnly() throws Exception { connect.effectiveHttpsConnectionContext( http.defaultClientHttpsContext()); // usage by us internally } - - @SuppressWarnings("unused") - public void compileOnlyBinding() throws Exception { - final Http http = Http.get(system()); - final HttpsConnectionContext httpsConnectionContext = null; - - http.bind(toHost("127.0.0.1")); // 80 - http.bind(toHost("127.0.0.1", 8080)); // 8080 - - http.bind(toHost("https://127.0.0.1")); // HTTPS 443 - http.bind(toHost("https://127.0.0.1", 9090)); // HTTPS 9090 - - http.bind(toHostHttps("127.0.0.1")); // HTTPS 443 - http.bind( - toHostHttps("127.0.0.1") - .withCustomHttpsContext(httpsConnectionContext)); // custom HTTPS 443 - - http.bind(toHostHttps("http://127.0.0.1")); // throws - } }