Skip to content

Commit

Permalink
chore: Stop using akka.util.DurationConverters (#4421)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren authored Sep 16, 2024
1 parent 4fbcbe4 commit 589173f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import akka.actor.ClassicActorSystemProvider
import akka.annotation.DoNotInherit
import akka.dispatch.ExecutionContexts
import akka.Done
import akka.util.JavaDurationConverters._

import scala.concurrent.duration.FiniteDuration
import scala.jdk.FutureConverters._
import scala.jdk.DurationConverters._

/**
* Represents a prospective HTTP server binding.
Expand Down Expand Up @@ -92,7 +92,7 @@ class ServerBinding private[http] (delegate: akka.http.scaladsl.Http.ServerBindi
*/
def whenTerminationSignalIssued: CompletionStage[java.time.Duration] =
delegate.whenTerminationSignalIssued
.map(deadline => deadline.time.asJava)(ExecutionContexts.parasitic)
.map(deadline => deadline.time.toJava)(ExecutionContexts.parasitic)
.asJava

/**
Expand All @@ -119,8 +119,7 @@ class ServerBinding private[http] (delegate: akka.http.scaladsl.Http.ServerBindi
* @param hardTerminationDeadline timeout after which all requests and connections shall be forcefully terminated
*/
def addToCoordinatedShutdown(hardTerminationDeadline: java.time.Duration, system: ClassicActorSystemProvider): ServerBinding = {
import akka.util.JavaDurationConverters._
delegate.addToCoordinatedShutdown(hardTerminationDeadline.asScala)(system)
delegate.addToCoordinatedShutdown(hardTerminationDeadline.toScala)(system)
this
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import akka.annotation.{ ApiMayChange, DoNotInherit }
import akka.http.impl.settings.ConnectionPoolSettingsImpl
import akka.http.impl.util.JavaMapping.Implicits._
import akka.http.javadsl.ClientTransport
import akka.util.JavaDurationConverters._

/**
* Public API but not intended for subclassing
Expand All @@ -27,7 +26,9 @@ abstract class ConnectionPoolSettings private[akka] () { self: ConnectionPoolSet
def getMaxRetries: Int = maxRetries
def getMaxOpenRequests: Int = maxOpenRequests
def getPipeliningLimit: Int = pipeliningLimit
def getMaxConnectionLifetime: JDuration = maxConnectionLifetime.asJava
def getMaxConnectionLifetime: JDuration =
if (maxConnectionLifetime.isFinite) JDuration.ofNanos(maxConnectionLifetime.toNanos)
else JDuration.ZERO
def getBaseConnectionBackoff: FiniteDuration = baseConnectionBackoff
def getMaxConnectionBackoff: FiniteDuration = maxConnectionBackoff
def getIdleTimeout: Duration = idleTimeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import java.nio.file.Path
import javax.net.ssl.SSLContext
import java.util.{ List => JList }
import akka.http.scaladsl.common.{ SSLContextFactory => ScalaSSLContextFactory }
import akka.util.JavaDurationConverters.JavaDurationOps
import com.typesafe.config.Config

import java.security.SecureRandom
import java.time.Duration
import java.util.Optional
import javax.net.ssl.SSLEngine
import scala.jdk.DurationConverters._
import scala.jdk.CollectionConverters._
import scala.jdk.OptionConverters.RichOptional

Expand Down Expand Up @@ -107,7 +107,7 @@ object SSLContextFactory {
*/
@ApiMayChange
def refreshingSSLEngineProvider(refreshAfter: Duration)(construct: akka.japi.function.Creator[SSLContext]): akka.japi.function.Creator[SSLEngine] =
() => ScalaSSLContextFactory.refreshingSSLEngineProvider(refreshAfter.asScala)(construct.create _)()
() => ScalaSSLContextFactory.refreshingSSLEngineProvider(refreshAfter.toScala)(construct.create _)()

/**
* Keeps a created SSLContext around for a `refreshAfter` period, sharing it among connections, then creates a new
Expand All @@ -122,5 +122,5 @@ object SSLContextFactory {
*/
@ApiMayChange
def refreshingSSLContextProvider(refreshAfter: Duration)(construct: akka.japi.function.Creator[SSLContext]): akka.japi.function.Creator[SSLContext] =
() => ScalaSSLContextFactory.refreshingSSLContextProvider(refreshAfter.asScala)(construct.create _)()
() => ScalaSSLContextFactory.refreshingSSLContextProvider(refreshAfter.toScala)(construct.create _)()
}

0 comments on commit 589173f

Please sign in to comment.