Skip to content

Commit

Permalink
twitter-server: Remove Netty3 from TwitterServer
Browse files Browse the repository at this point in the history
Problem

TwitterServer contains a dependency on Netty 3 due to its use of
Netty 3's `QueryStringDecoder`.

Solution

Change `HttpUtils` to use Netty 4's `QueryStringDecoder` and entirely
remove the dependency on Netty 3 from TwitterServer.

JIRA Issues: CSL-7865

Differential Revision: https://phabricator.twitter.biz/D328148
  • Loading branch information
ryanoneill authored and jenkins committed Jun 14, 2019
1 parent 85183d2 commit 0d80cea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Note that ``PHAB_ID=#`` and ``RB_ID=#`` correspond to associated messages in com
Unreleased
----------

Changes
~~~~~~~

* Remove the TwitterServer dependency on Netty 3. ``PHAB_ID=D328148``

19.5.1
------

Expand Down
5 changes: 1 addition & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ val jacksonLibs = Seq(
val opencensusVersion = "0.19.1"
val slf4jVersion = "1.7.21"

val netty3Lib = "io.netty" % "netty" % "3.10.1.Final"

def util(which: String) = "com.twitter" %% ("util-"+which) % releaseVersion
def finagle(which: String) = "com.twitter" %% ("finagle-"+which) % releaseVersion

Expand Down Expand Up @@ -132,8 +130,7 @@ lazy val twitterServer = (project in file("server"))
util("registry"),
util("slf4j-api"),
util("slf4j-jul-bridge"),
util("tunable"),
netty3Lib
util("tunable")
),
libraryDependencies ++= jacksonLibs)

Expand Down
1 change: 0 additions & 1 deletion server/src/main/scala/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ scala_library(
"3rdparty/jvm/com/fasterxml/jackson/core:jackson-core",
"3rdparty/jvm/com/fasterxml/jackson/core:jackson-databind",
"3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala",
"3rdparty/jvm/io/netty",
"3rdparty/jvm/io/netty:netty4",
"3rdparty/jvm/org/slf4j:slf4j-api",
"finagle/finagle-base-http/src/main/scala",
Expand Down
10 changes: 5 additions & 5 deletions server/src/main/scala/com/twitter/server/util/HttpUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.twitter.finagle.Service
import com.twitter.finagle.http.{MediaType, Request, Response, Status, Version, HttpMuxer}
import com.twitter.io.Buf
import com.twitter.util.{Future, Time, Closable}
import org.jboss.netty.handler.codec.http.QueryStringDecoder
import io.netty.handler.codec.http.QueryStringDecoder
import scala.collection.JavaConverters._
import scala.collection.{Map, Seq}

Expand Down Expand Up @@ -42,15 +42,15 @@ private[server] object HttpUtils {
*/
def expectsHtml(req: Request): Boolean = {
val decoder = new QueryStringDecoder(req.uri)
decoder.getPath.endsWith(".html") || accepts(req, MediaType.Html)
decoder.path().endsWith(".html") || accepts(req, MediaType.Html)
}

/**
* Determines if the client expects to receive `application/json` content type.
*/
def expectsJson(req: Request): Boolean = {
val decoder = new QueryStringDecoder(req.uri)
decoder.getPath.endsWith(".json") || accepts(req, MediaType.Json)
decoder.path().endsWith(".json") || accepts(req, MediaType.Json)
}

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ private[server] object HttpUtils {
/** Parse uri into (path, params) */
def parse(uri: String): (String, Map[String, Seq[String]]) = {
val qsd = new QueryStringDecoder(uri)
val params = qsd.getParameters.asScala.mapValues { _.asScala.toSeq }
(qsd.getPath, params)
val params = qsd.parameters().asScala.mapValues(_.asScala.toSeq)
(qsd.path(), params)
}
}

0 comments on commit 0d80cea

Please sign in to comment.