Skip to content

Commit

Permalink
Fix various scala3 compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
farmdawgnation committed Aug 17, 2024
1 parent 908abc1 commit 986246b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion core/src/main/scala/as/core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.asynchttpclient.handler.resumable._
import java.io._
import java.nio.charset.Charset
import java.io.Closeable
import io.netty.handler.codec.http.HttpHeaders

object Response {
def apply[T](f: asynchttpclient.Response => T) = f
Expand All @@ -30,17 +31,20 @@ object Bytes extends (asynchttpclient.Response => Array[Byte]) {
def apply(r: asynchttpclient.Response) = r.getResponseBodyAsBytes
}

object File extends {
abstract class FileApply {
def apply(file: java.io.File) = {
val fileHandler = new RandomAccessFile(file, "rw")

val resumableHandler = new ResumableAsyncHandler
with OkHandler[asynchttpclient.Response]
with CloseResourcesOnThrowableHandler[asynchttpclient.Response] {
override lazy val closeable: Seq[Closeable] = Seq(fileHandler)
override def onTrailingHeadersReceived(headers: HttpHeaders): asynchttpclient.AsyncHandler.State = super[ResumableAsyncHandler].onTrailingHeadersReceived(headers)
}

resumableHandler
.setResumableListener(new ResumableRandomAccessFileListener(fileHandler))
}
}

object File extends FileApply
5 changes: 4 additions & 1 deletion core/src/main/scala/handlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.asynchttpclient.{
Response, AsyncCompletionHandler, AsyncHandler,
HttpResponseStatus
}
import io.netty.handler.codec.http.HttpHeaders

/**
* Builds tuples of (Request, AsyncHandler) for passing to Http#apply.
Expand All @@ -28,7 +29,9 @@ class FunctionHandler[T](f: Response => T) extends AsyncCompletionHandler[T] {
}

class OkFunctionHandler[T](f: Response => T)
extends FunctionHandler[T](f) with OkHandler[T]
extends FunctionHandler[T](f) with OkHandler[T] {
override def onTrailingHeadersReceived(headers: HttpHeaders): AsyncHandler.State = super[FunctionHandler].onTrailingHeadersReceived(headers)
}

trait OkHandler[T] extends AsyncHandler[T] {
abstract override def onStatusReceived(status: HttpResponseStatus) = {
Expand Down
2 changes: 1 addition & 1 deletion json4sjackson/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description :=
"Dispatch module providing json4s support"

libraryDependencies ++= Seq(
"org.json4s" %% "json4s-jackson" % "3.6.7",
"org.json4s" %% "json4s-jackson" % "4.1.0-M6",
"ws.unfiltered" %% "unfiltered-netty-server" % "0.13.0-M2" % "test"
)
2 changes: 1 addition & 1 deletion json4sjackson/src/main/scala/as/json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import org.asynchttpclient.Response

object Json extends (Response => JValue) {
def apply(r: Response) =
(dispatch.as.String andThen (s => parse(StringInput(s), true)))(r)
(dispatch.as.String andThen (s => parse(s, true)))(r)
}
2 changes: 1 addition & 1 deletion json4snative/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name := "dispatch-json4s-native"
description :=
"Dispatch module providing json4s native support"

val json4sVersion = "3.6.7"
val json4sVersion = "4.1.0-M6"

libraryDependencies ++= Seq(
"org.json4s" %% "json4s-core" % json4sVersion,
Expand Down
2 changes: 1 addition & 1 deletion json4snative/src/main/scala/as/json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import org.asynchttpclient.Response

object Json extends (Response => JValue) {
def apply(r: Response) =
(dispatch.as.String andThen (s => parse(StringInput(s), true)))(r)
(dispatch.as.String andThen (s => parse(s, true)))(r)
}

0 comments on commit 986246b

Please sign in to comment.