Skip to content

Commit

Permalink
util-core: Pipe handles copying
Browse files Browse the repository at this point in the history
Problem/Solution:

`copy` methods that copy from Readers to Writers should not be hosted under
Reader. they are equally related to both parties. Moving them to `Pipe`.

Result:

Scala 2.12 supports Java calling companion object methods directly without
many `$` and no users are using `copy`. I don't feel we should add Pipes.java
for these two method temporarily until we drop 2.11 support. Having them still
under Readers.java before removal.

JIRA Issues: CSL-6756

Differential Revision: https://phabricator.twitter.biz/D393650
  • Loading branch information
yufangong authored and jenkins committed Nov 4, 2019
1 parent a5bce43 commit ac53360
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/main/scala/com/twitter/server/view/IndexView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.twitter.finagle.http.Method
import com.twitter.finagle.http.Method.{Get, Post}
import com.twitter.finagle.{Service, SimpleFilter}
import com.twitter.finagle.http.{Request, Response}
import com.twitter.io.{Buf, BufReader, Reader}
import com.twitter.io.{Buf, BufReader, Reader, Pipe}
import com.twitter.server.util.HtmlUtils.escapeHtml
import com.twitter.server.util.HttpUtils.{expectsHtml, newResponse}
import com.twitter.util.Future
Expand Down Expand Up @@ -148,7 +148,7 @@ class IndexView(title: String, uri: String, index: () => Seq[IndexView.Entry])
response.contentType = "text/html;charset=UTF-8"
response.setChunked(true)
val reader = render(title, uri, index().sorted, res.reader)
Reader.copy(reader, response.writer) ensure response.writer.close()
Pipe.copy(reader, response.writer) ensure response.writer.close()
Future.value(response)

case res =>
Expand Down

0 comments on commit ac53360

Please sign in to comment.