Skip to content

Commit

Permalink
Merge pull request #560 from http4s/scalafmt-3.0.2
Browse files Browse the repository at this point in the history
Update `Scalafmt` to 3.0.2
  • Loading branch information
danicheg authored Sep 7, 2021
2 parents 3e2da66 + 1d1a87b commit 3d1b15e
Show file tree
Hide file tree
Showing 66 changed files with 729 additions and 567 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 2.7.5
version = 3.0.2

style = default

Expand Down
51 changes: 35 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,32 @@ lazy val commonSettings = Seq(
},
run / fork := true,
developers ++= List(
Developer("bryce-anderson" , "Bryce L. Anderson" , "[email protected]" , url("https://github.com/bryce-anderson")),
Developer("rossabaker" , "Ross A. Baker" , "[email protected]" , url("https://github.com/rossabaker")),
Developer("ChristopherDavenport" , "Christopher Davenport" , "[email protected]" , url("https://github.com/ChristopherDavenport"))
Developer(
"bryce-anderson",
"Bryce L. Anderson",
"[email protected]",
url("https://github.com/bryce-anderson")),
Developer(
"rossabaker",
"Ross A. Baker",
"[email protected]",
url("https://github.com/rossabaker")),
Developer(
"ChristopherDavenport",
"Christopher Davenport",
"[email protected]",
url("https://github.com/ChristopherDavenport"))
),

licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),

homepage := Some(url("https://github.com/http4s/blaze")),

scmInfo := Some(
ScmInfo(
url("https://github.com/http4s/blaze"),
"scm:git:https://github.com/http4s/blaze.git",
Some("scm:git:[email protected]:http4s/blaze.git")
)
),
startYear := Some(2014),
startYear := Some(2014)
)

ThisBuild / githubWorkflowJavaVersions := Seq("[email protected]")
Expand All @@ -65,7 +74,8 @@ ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("validate-ci"))
)

lazy val blaze = project.in(file("."))
lazy val blaze = project
.in(file("."))
.enablePlugins(Http4sOrgPlugin)
.enablePlugins(NoPublishPlugin)
.settings(commonSettings)
Expand Down Expand Up @@ -93,7 +103,8 @@ lazy val core = Project("blaze-core", file("core"))
buildInfoOptions += BuildInfoOption.BuildTime,
mimaBinaryIssueFilters ++= Seq(
// private constructor for which there are no sensible defaults
ProblemFilters.exclude[DirectMissingMethodProblem]("org.http4s.blaze.channel.nio1.NIO1SocketServerGroup.this")
ProblemFilters.exclude[DirectMissingMethodProblem](
"org.http4s.blaze.channel.nio1.NIO1SocketServerGroup.this")
)
)
.dependsOn(testkit % Test)
Expand All @@ -107,15 +118,19 @@ lazy val http = Project("blaze-http", file("http"))
// Test Dependencies
libraryDependencies += asyncHttpClient % Test,
mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[MissingClassProblem]("org.http4s.blaze.http.http2.PingManager$PingState"),
ProblemFilters.exclude[MissingClassProblem]("org.http4s.blaze.http.http2.PingManager$PingState$"),
ProblemFilters.exclude[MissingClassProblem]("org.http4s.blaze.http.http2.client.ALPNClientSelector$ClientProvider"),
ProblemFilters.exclude[MissingClassProblem]("org.http4s.blaze.http.http2.server.ALPNServerSelector$ServerProvider")
ProblemFilters.exclude[MissingClassProblem](
"org.http4s.blaze.http.http2.PingManager$PingState"),
ProblemFilters.exclude[MissingClassProblem](
"org.http4s.blaze.http.http2.PingManager$PingState$"),
ProblemFilters.exclude[MissingClassProblem](
"org.http4s.blaze.http.http2.client.ALPNClientSelector$ClientProvider"),
ProblemFilters.exclude[MissingClassProblem](
"org.http4s.blaze.http.http2.server.ALPNServerSelector$ServerProvider")
)
)
.dependsOn(testkit % Test, core % "test->test;compile->compile")

lazy val examples = Project("blaze-examples",file("examples"))
lazy val examples = Project("blaze-examples", file("examples"))
.enablePlugins(NoPublishPlugin)
.settings(commonSettings)
.settings(Revolver.settings)
Expand All @@ -124,7 +139,11 @@ lazy val examples = Project("blaze-examples",file("examples"))
/* Helper Functions */

// use it in the local development process
addCommandAlias("validate", ";scalafmtCheckAll ;javafmtCheckAll ;+test:compile ;test ;unusedCompileDependenciesTest ;mimaReportBinaryIssues")
addCommandAlias(
"validate",
";scalafmtCheckAll ;scalafmtSbtCheck ;javafmtCheckAll ;+test:compile ;test ;unusedCompileDependenciesTest ;mimaReportBinaryIssues")

// use it in the CI pipeline
addCommandAlias("validate-ci", ";scalafmtCheckAll ;javafmtCheckAll ;test ;unusedCompileDependenciesTest ;mimaReportBinaryIssues")
addCommandAlias(
"validate-ci",
";scalafmtCheckAll ;scalafmtSbtCheck ;javafmtCheckAll ;test ;unusedCompileDependenciesTest ;mimaReportBinaryIssues")
22 changes: 13 additions & 9 deletions core/src/main/scala/org/http4s/blaze/channel/ServerChannel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ abstract class ServerChannel extends Closeable { self =>

/** Close out any resources associated with the [[ServerChannel]]
*
* @note Regardless of the number of times `close()` is called
* this method will only be called once.
* @note
* Regardless of the number of times `close()` is called this method will only be called once.
*/
protected def closeChannel(): Unit

Expand All @@ -46,7 +46,8 @@ abstract class ServerChannel extends Closeable { self =>

/** Close the [[ServerChannel]] and execute any shutdown hooks
*
* @note this method is idempotent
* @note
* this method is idempotent
*/
final def close(): Unit = {
val hooks = shutdownHooks.synchronized {
Expand All @@ -64,8 +65,8 @@ abstract class ServerChannel extends Closeable { self =>
scheduleHooks(hooks)
}

/** Wait for this server channel to close, including execution of all successfully
* registered shutdown hooks.
/** Wait for this server channel to close, including execution of all successfully registered
* shutdown hooks.
*/
final def join(): Unit =
shutdownHooks.synchronized {
Expand All @@ -75,11 +76,14 @@ abstract class ServerChannel extends Closeable { self =>

/** Add code to be executed when the [[ServerChannel]] is closed
*
* @note There are no guarantees as to order of shutdown hook execution
* or that they will be executed sequentially.
* @note
* There are no guarantees as to order of shutdown hook execution or that they will be executed
* sequentially.
*
* @param f hook to execute on shutdown
* @return true if the hook was successfully registered, false otherwise.
* @param f
* hook to execute on shutdown
* @return
* true if the hook was successfully registered, false otherwise.
*/
final def addShutdownHook(f: () => Unit)(implicit
ec: ExecutionContext = Execution.directec): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import scala.util.Try

/** Abstraction for binding a server socket and handling connections.
*
* @note Implementations may have resources associated with
* them before binding any sockets and should be closed.
* @note
* Implementations may have resources associated with them before binding any sockets and should
* be closed.
*/
trait ServerChannelGroup {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ private[nio1] object NIO1HeadStage {

/** Performs the read operation
*
* @param scratch a ByteBuffer in which to load read data. The method
* doesn't take and ownership interest in the buffer, eg it's
* reference is not retained.
* @return a `Try` representing successfully loading data into `scratch`, or
* the failure cause.
* @param scratch
* a ByteBuffer in which to load read data. The method doesn't take and ownership interest in
* the buffer, eg it's reference is not retained.
* @return
* a `Try` representing successfully loading data into `scratch`, or the failure cause.
*/
private def performRead(ch: NIO1ClientChannel, scratch: ByteBuffer, size: Int): Try[Unit] =
try {
Expand All @@ -64,8 +64,10 @@ private[nio1] object NIO1HeadStage {
}

/** Perform the write operation for this channel
* @param buffers buffers to be written to the channel
* @return a WriteResult that is one of Complete, Incomplete or WriteError(e: Exception)
* @param buffers
* buffers to be written to the channel
* @return
* a WriteResult that is one of Complete, Incomplete or WriteError(e: Exception)
*/
private def performWrite(
ch: NIO1ClientChannel,
Expand Down Expand Up @@ -338,8 +340,7 @@ private[nio1] final class NIO1HeadStage(
}
}

/** Unsets a channel interest
* only to be called by the SelectorLoop thread
/** Unsets a channel interest only to be called by the SelectorLoop thread
*/
private[this] def unsetOp(op: Int): Unit =
// assert(Thread.currentThread() == loop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ object NIO1SocketServerGroup {

/** Create a new [[NIO1SocketServerGroup]] from the [[SelectorLoopPool]].
*
* @note The worker pool is not owned by the group and therefore not
* shutdown when the group is shutdown.
* @note
* The worker pool is not owned by the group and therefore not shutdown when the group is
* shutdown.
*/
def create(
acceptorPool: SelectorLoopPool,
Expand All @@ -70,11 +71,9 @@ object NIO1SocketServerGroup {
): ServerChannelGroup =
new NIO1SocketServerGroup(acceptorPool, workerPool, channelOptions, maxConnections)

/** Create a new [[NIO1SocketServerGroup]] with a fresh [[FixedSelectorPool]
* ]
*
* The resulting [[ServerChannelGroup]] takes ownership of the created pool,
* shutting it down when the group is shutdown.
/** Create a new [[NIO1SocketServerGroup]] with a fresh
* [[FixedSelectorPool] ] The resulting [[ServerChannelGroup]] takes ownership of the created
* pool, shutting it down when the group is shutdown.
*/
def fixed(
workerThreads: Int = DefaultPoolSize,
Expand Down Expand Up @@ -114,9 +113,10 @@ object NIO1SocketServerGroup {

/** A thread resource group for NIO1 network operations
*
* @param workerPool [[SelectorLoopPool]] that will belong to this group. The group
* assumes responsibility for shutting it down. Shutting down the
* pool after giving it to this group will result in undefined behavior.
* @param workerPool
* [[SelectorLoopPool]] that will belong to this group. The group assumes responsibility for
* shutting it down. Shutting down the pool after giving it to this group will result in
* undefined behavior.
*/
private final class NIO1SocketServerGroup private (
acceptorPool: SelectorLoopPool,
Expand Down Expand Up @@ -247,8 +247,8 @@ private final class NIO1SocketServerGroup private (
toClose.foreach(_.close())
}

/** Create a [[org.http4s.blaze.channel.ServerChannel]] that will serve the
* services on the requisite sockets
/** Create a [[org.http4s.blaze.channel.ServerChannel]] that will serve the services on the
* requisite sockets
*/
override def bind(
address: InetSocketAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ import java.nio.ByteBuffer

/** Type that can be registered with a [[SelectorLoop]]
*
* When registered with a `SelectorLoop` it will be notified
* when it has events ready.
* When registered with a `SelectorLoop` it will be notified when it has events ready.
*/
private trait Selectable {

/** Called by the `SelectorLoop` when events are ready
*
* @param scratch a `ByteBuffer` that can be used for scratch area.
* This buffer is strictly borrowed for the life of the
* method call and will be passed to other `Selectable`
* instances.
* @param scratch
* a `ByteBuffer` that can be used for scratch area. This buffer is strictly borrowed for the
* life of the method call and will be passed to other `Selectable` instances.
*/
def opsReady(scratch: ByteBuffer): Unit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ import scala.util.control.{ControlThrowable, NonFatal}

/** A special thread that listens for events on the provided selector.
*
* @param selector `Selector` to listen on.
* @param bufferSize Size of the scratch buffer instantiated for this thread.
* @param threadFactory Factory to make the `Thread` instance to run the loop.
* @param selector
* `Selector` to listen on.
* @param bufferSize
* Size of the scratch buffer instantiated for this thread.
* @param threadFactory
* Factory to make the `Thread` instance to run the loop.
*
* @note when the `SelectorLoop` is closed all registered `Selectable`s
* are closed with it.
* @note
* when the `SelectorLoop` is closed all registered `Selectable`s are closed with it.
*/
final class SelectorLoop(
selector: Selector,
Expand Down Expand Up @@ -73,9 +76,8 @@ final class SelectorLoop(

/** Schedule the provided `Runnable` for execution, potentially running it now
*
* The provided task may be executed *now* if the calling thread is `this`
* `SelectorLoop`, otherwise it is added to the task queue to be executed by
* the `SelectorLoop` thread later.
* The provided task may be executed *now* if the calling thread is `this` `SelectorLoop`,
* otherwise it is added to the task queue to be executed by the `SelectorLoop` thread later.
*/
@inline
@throws[RejectedExecutionException]
Expand All @@ -87,12 +89,12 @@ final class SelectorLoop(

/** Schedule to provided `Runnable` for execution later
*
* The task will be added to the end of the queue of tasks scheduled
* for execution regardless of where this method is called.
* The task will be added to the end of the queue of tasks scheduled for execution regardless of
* where this method is called.
*
* @see `executeTask` for a method that will execute the task now if
* the calling thread is `this` `SelectorLoop`, or schedule it for
* later otherwise.
* @see
* `executeTask` for a method that will execute the task now if the calling thread is `this`
* `SelectorLoop`, or schedule it for later otherwise.
*/
@throws[RejectedExecutionException]
def enqueueTask(runnable: Runnable): Unit =
Expand All @@ -116,11 +118,11 @@ final class SelectorLoop(

/** Initialize a new `Selectable` channel
*
* The `SelectableChannel` is added to the selector loop the
* `Selectable` will be notified when it has events ready.
* The `SelectableChannel` is added to the selector loop the `Selectable` will be notified when
* it has events ready.
*
* @note the underlying `SelectableChannel` _must_ be
* configured in non-blocking mode.
* @note
* the underlying `SelectableChannel` _must_ be configured in non-blocking mode.
*/
def initChannel(
ch: NIO1Channel,
Expand Down Expand Up @@ -245,16 +247,16 @@ final class SelectorLoop(
throw ex
}

/** A Runnable that will only execute in this selector loop and provides
* access to the `SelectorLoop`s scratch buffer.
/** A Runnable that will only execute in this selector loop and provides access to the
* `SelectorLoop`s scratch buffer.
*/
abstract class LoopRunnable extends Runnable {

/** Execute the task with the borrowed scratch `ByteBuffer`
*
* @param scratch a `ByteBuffer` that is owned by the parent
* `SelectorLoop`, and as such, the executing task
* _must not_ retain a refer to it.
* @param scratch
* a `ByteBuffer` that is owned by the parent `SelectorLoop`, and as such, the executing task
* _must not_ retain a refer to it.
*/
def run(scratch: ByteBuffer): Unit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ import scala.util.control.NonFatal
*
* Provides a way to easily make TCP connections which can then serve as the Head for a pipeline
*
* @param bufferSize default buffer size to perform reads
* @param group The `AsynchronousChannelGroup` which will manage the connection.
* `None` will use the system default
* @param bufferSize
* default buffer size to perform reads
* @param group
* The `AsynchronousChannelGroup` which will manage the connection. `None` will use the system
* default
*/
final class ClientChannelFactory(
bufferSize: Int = DefaultBufferSize,
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/org/http4s/blaze/channel/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ package object channel {
val DefaultPoolSize: Int =
math.max(4, Runtime.getRuntime.availableProcessors() + 1)

/** Default max number of connections that can be active at any time.
* A negative number means that there is no max.
/** Default max number of connections that can be active at any time. A negative number means that
* there is no max.
*/
val DefaultMaxConnections: Int = 512
}
Loading

0 comments on commit 3d1b15e

Please sign in to comment.