From 32810e1f1da45fff8dd79f41b466e6735de4b356 Mon Sep 17 00:00:00 2001 From: Nafer Sanabria Date: Sun, 10 Jul 2016 10:41:57 -0500 Subject: [PATCH] =htc, doc replace usages of deprecated methods of FileIO (#20928) --- .../scala/akka/cluster/ddata/Replicator.scala | 8 ++++---- .../stream/migration-guide-2.0-2.4-java.rst | 4 ++-- akka-docs/rst/java/stream/stream-io.rst | 2 +- akka-docs/rst/java/stream/stream-quickstart.rst | 2 +- .../server/FileUploadExamplesSpec.scala | 2 +- .../stream/migration-guide-2.0-2.4-scala.rst | 4 ++-- akka-docs/rst/scala/stream/stream-io.rst | 2 +- .../rst/scala/stream/stream-quickstart.rst | 2 +- .../directives/FileAndResourceDirectives.scala | 5 ++--- .../directives/FileUploadDirectives.scala | 6 +++--- .../main/scala/akka/stream/javadsl/FileIO.scala | 17 +++++++++++++---- .../scala/akka/stream/scaladsl/FileIO.scala | 6 +++--- 12 files changed, 34 insertions(+), 26 deletions(-) diff --git a/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala b/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala index 8ccb288c0e..74a4d43553 100644 --- a/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala +++ b/akka-distributed-data/src/main/scala/akka/cluster/ddata/Replicator.scala @@ -276,14 +276,14 @@ object Replicator { final case class Subscribe[A <: ReplicatedData](key: Key[A], subscriber: ActorRef) extends ReplicatorMessage /** * Unregister a subscriber. - * - * @see [[Replicator.Subscribe]] + * + * @see [[Replicator.Subscribe]] */ final case class Unsubscribe[A <: ReplicatedData](key: Key[A], subscriber: ActorRef) extends ReplicatorMessage /** * The data value is retrieved with [[#get]] using the typed key. - * - * @see [[Replicator.Subscribe]] + * + * @see [[Replicator.Subscribe]] */ final case class Changed[A <: ReplicatedData](key: Key[A])(data: A) extends ReplicatorMessage { /** diff --git a/akka-docs/rst/java/stream/migration-guide-2.0-2.4-java.rst b/akka-docs/rst/java/stream/migration-guide-2.0-2.4-java.rst index eeabc82333..b00fe25d92 100644 --- a/akka-docs/rst/java/stream/migration-guide-2.0-2.4-java.rst +++ b/akka-docs/rst/java/stream/migration-guide-2.0-2.4-java.rst @@ -136,8 +136,8 @@ IO Sources / Sinks materialize IOResult Materialized values of the following sources and sinks: - * ``FileIO.fromFile`` - * ``FileIO.toFile`` + * ``FileIO.fromPath`` + * ``FileIO.toPath`` * ``StreamConverters.fromInputStream`` * ``StreamConverters.fromOutputStream`` diff --git a/akka-docs/rst/java/stream/stream-io.rst b/akka-docs/rst/java/stream/stream-io.rst index 71f2786ae5..598b4ee04f 100644 --- a/akka-docs/rst/java/stream/stream-io.rst +++ b/akka-docs/rst/java/stream/stream-io.rst @@ -100,7 +100,7 @@ Akka Streams provide simple Sources and Sinks that can work with :class:`ByteStr on files. -Streaming data from a file is as easy as creating a `FileIO.fromFile` given a target file, and an optional +Streaming data from a file is as easy as creating a `FileIO.fromPath` given a target path, and an optional ``chunkSize`` which determines the buffer size determined as one "element" in such stream: .. includecode:: ../code/docs/stream/io/StreamFileDocTest.java#file-source diff --git a/akka-docs/rst/java/stream/stream-quickstart.rst b/akka-docs/rst/java/stream/stream-quickstart.rst index 12d9016502..c3c7e73ee9 100644 --- a/akka-docs/rst/java/stream/stream-quickstart.rst +++ b/akka-docs/rst/java/stream/stream-quickstart.rst @@ -90,7 +90,7 @@ accepts strings as its input and when materialized it will create auxiliary information of type ``CompletionStage`` (when chaining operations on a :class:`Source` or :class:`Flow` the type of the auxiliary information—called the “materialized value”—is given by the leftmost starting point; since we want -to retain what the ``FileIO.toFile`` sink has to offer, we need to say +to retain what the ``FileIO.toPath`` sink has to offer, we need to say ``Keep.right()``). We can use the new and shiny :class:`Sink` we just created by diff --git a/akka-docs/rst/scala/code/docs/http/scaladsl/server/FileUploadExamplesSpec.scala b/akka-docs/rst/scala/code/docs/http/scaladsl/server/FileUploadExamplesSpec.scala index 1a52983dcf..5bdf363a14 100644 --- a/akka-docs/rst/scala/code/docs/http/scaladsl/server/FileUploadExamplesSpec.scala +++ b/akka-docs/rst/scala/code/docs/http/scaladsl/server/FileUploadExamplesSpec.scala @@ -35,7 +35,7 @@ class FileUploadExamplesSpec extends RoutingSpec { // stream into a file as the chunks of it arrives and return a future // file to where it got stored val file = File.createTempFile("upload", "tmp") - b.entity.dataBytes.runWith(FileIO.toFile(file)).map(_ => + b.entity.dataBytes.runWith(FileIO.toPath(file.toPath)).map(_ => (b.name -> file)) case b: BodyPart => diff --git a/akka-docs/rst/scala/stream/migration-guide-2.0-2.4-scala.rst b/akka-docs/rst/scala/stream/migration-guide-2.0-2.4-scala.rst index 4f90f6162f..7d0bb64d8d 100644 --- a/akka-docs/rst/scala/stream/migration-guide-2.0-2.4-scala.rst +++ b/akka-docs/rst/scala/stream/migration-guide-2.0-2.4-scala.rst @@ -138,8 +138,8 @@ IO Sources / Sinks materialize IOResult Materialized values of the following sources and sinks: - * ``FileIO.fromFile`` - * ``FileIO.toFile`` + * ``FileIO.fromPath`` + * ``FileIO.toPath`` * ``StreamConverters.fromInputStream`` * ``StreamConverters.fromOutputStream`` diff --git a/akka-docs/rst/scala/stream/stream-io.rst b/akka-docs/rst/scala/stream/stream-io.rst index 760bff8725..178b861b11 100644 --- a/akka-docs/rst/scala/stream/stream-io.rst +++ b/akka-docs/rst/scala/stream/stream-io.rst @@ -100,7 +100,7 @@ Akka Streams provide simple Sources and Sinks that can work with :class:`ByteStr on files. -Streaming data from a file is as easy as creating a `FileIO.fromFile` given a target file, and an optional +Streaming data from a file is as easy as creating a `FileIO.fromPath` given a target path, and an optional ``chunkSize`` which determines the buffer size determined as one "element" in such stream: .. includecode:: ../code/docs/stream/io/StreamFileDocSpec.scala#file-source diff --git a/akka-docs/rst/scala/stream/stream-quickstart.rst b/akka-docs/rst/scala/stream/stream-quickstart.rst index cdc37c1da2..cc599e73f7 100644 --- a/akka-docs/rst/scala/stream/stream-quickstart.rst +++ b/akka-docs/rst/scala/stream/stream-quickstart.rst @@ -91,7 +91,7 @@ accepts strings as its input and when materialized it will create auxiliary information of type ``Future[IOResult]`` (when chaining operations on a :class:`Source` or :class:`Flow` the type of the auxiliary information—called the “materialized value”—is given by the leftmost starting point; since we want -to retain what the ``FileIO.toFile`` sink has to offer, we need to say +to retain what the ``FileIO.toPath`` sink has to offer, we need to say ``Keep.right``). We can use the new and shiny :class:`Sink` we just created by diff --git a/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileAndResourceDirectives.scala b/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileAndResourceDirectives.scala index c8edaa8bc0..a7e802aeb0 100644 --- a/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileAndResourceDirectives.scala +++ b/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileAndResourceDirectives.scala @@ -9,14 +9,13 @@ import java.io.File import java.net.{ URI, URL } import akka.http.javadsl.model -import akka.http.javadsl.model.RequestEntity import akka.stream.ActorAttributes import akka.stream.scaladsl.{ FileIO, StreamConverters } import scala.annotation.tailrec import akka.actor.ActorSystem import akka.event.LoggingAdapter -import akka.http.scaladsl.marshalling.{ Marshaller, Marshalling, ToEntityMarshaller } +import akka.http.scaladsl.marshalling.{ Marshaller, ToEntityMarshaller } import akka.http.scaladsl.model._ import akka.http.scaladsl.model.headers._ import akka.http.impl.util._ @@ -70,7 +69,7 @@ trait FileAndResourceDirectives { withRangeSupportAndPrecompressedMediaTypeSupportAndExtractSettings { settings ⇒ complete { HttpEntity.Default(contentType, file.length, - FileIO.fromFile(file).withAttributes(ActorAttributes.dispatcher(settings.fileIODispatcher))) + FileIO.fromPath(file.toPath).withAttributes(ActorAttributes.dispatcher(settings.fileIODispatcher))) } } } else complete(HttpEntity.Empty) diff --git a/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileUploadDirectives.scala b/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileUploadDirectives.scala index 36045a88f7..3f497c4f8e 100644 --- a/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileUploadDirectives.scala +++ b/akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileUploadDirectives.scala @@ -4,10 +4,10 @@ package akka.http.scaladsl.server.directives import java.io.File - -import akka.http.scaladsl.server.{ MissingFormFieldRejection, Directive1 } +import akka.http.scaladsl.server.{ Directive1, MissingFormFieldRejection } import akka.http.scaladsl.model.{ ContentType, Multipart } import akka.util.ByteString + import scala.concurrent.Future import scala.util.{ Failure, Success } import akka.stream.scaladsl._ @@ -41,7 +41,7 @@ trait FileUploadDirectives { case (fileInfo, bytes) ⇒ val destination = File.createTempFile("akka-http-upload", ".tmp") - val uploadedF: Future[(FileInfo, File)] = bytes.runWith(FileIO.toFile(destination)) + val uploadedF: Future[(FileInfo, File)] = bytes.runWith(FileIO.toPath(destination.toPath)) .map(_ ⇒ (fileInfo, destination)) onComplete[(FileInfo, File)](uploadedF).flatMap { diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/FileIO.scala b/akka-stream/src/main/scala/akka/stream/javadsl/FileIO.scala index 0b452c4bfc..9fde2002e2 100644 --- a/akka-stream/src/main/scala/akka/stream/javadsl/FileIO.scala +++ b/akka-stream/src/main/scala/akka/stream/javadsl/FileIO.scala @@ -34,7 +34,7 @@ object FileIO { def toFile(f: File): javadsl.Sink[ByteString, CompletionStage[IOResult]] = toPath(f.toPath) /** - * Creates a Sink that writes incoming [[ByteString]] elements to the given file. + * Creates a Sink that writes incoming [[ByteString]] elements to the given file path. * Overwrites existing files, if you want to append to an existing file use [[#file(Path, util.Set[StandardOpenOption])]]. * * Materializes a [[java.util.concurrent.CompletionStage]] of [[IOResult]] that will be completed with the size of the file (in bytes) at the streams completion, @@ -43,7 +43,7 @@ object FileIO { * You can configure the default dispatcher for this Source by changing the `akka.stream.blocking-io-dispatcher` or * set it for a given Source by using [[ActorAttributes]]. * - * @param f The file to write to + * @param f The file path to write to */ def toPath(f: Path): javadsl.Sink[ByteString, CompletionStage[IOResult]] = new Sink(scaladsl.FileIO.toPath(f).toCompletionStage()) @@ -65,7 +65,7 @@ object FileIO { toPath(f.toPath) /** - * Creates a Sink that writes incoming [[ByteString]] elements to the given file. + * Creates a Sink that writes incoming [[ByteString]] elements to the given file path. * * Materializes a [[java.util.concurrent.CompletionStage]] of [[IOResult]] that will be completed with the size of the file (in bytes) at the streams completion, * and a possible exception if IO operation was not completed successfully. @@ -73,7 +73,7 @@ object FileIO { * You can configure the default dispatcher for this Source by changing the `akka.stream.blocking-io-dispatcher` or * set it for a given Source by using [[ActorAttributes]]. * - * @param f The file to write to + * @param f The file path to write to * @param options File open options */ def toPath(f: Path, options: util.Set[StandardOpenOption]): javadsl.Sink[ByteString, CompletionStage[IOResult]] = @@ -89,6 +89,8 @@ object FileIO { * * It materializes a [[java.util.concurrent.CompletionStage]] of [[IOResult]] containing the number of bytes read from the source file upon completion, * and a possible exception if IO operation was not completed successfully. + * + * @param f the file to read from */ @deprecated("Use `fromPath` instead.", "2.4.5") def fromFile(f: File): javadsl.Source[ByteString, CompletionStage[IOResult]] = fromPath(f.toPath) @@ -103,6 +105,8 @@ object FileIO { * * It materializes a [[java.util.concurrent.CompletionStage]] of [[IOResult]] containing the number of bytes read from the source file upon completion, * and a possible exception if IO operation was not completed successfully. + * + * @param f the file path to read from */ def fromPath(f: Path): javadsl.Source[ByteString, CompletionStage[IOResult]] = fromPath(f, 8192) @@ -116,6 +120,8 @@ object FileIO { * * It materializes a [[java.util.concurrent.CompletionStage]] of [[IOResult]] containing the number of bytes read from the source file upon completion, * and a possible exception if IO operation was not completed successfully. + * @param f the file to read from + * @param chunkSize the size of each read operation */ @deprecated("Use `fromPath` instead.", "2.4.5") def fromFile(f: File, chunkSize: Int): javadsl.Source[ByteString, CompletionStage[IOResult]] = @@ -131,6 +137,9 @@ object FileIO { * * It materializes a [[java.util.concurrent.CompletionStage]] of [[IOResult]] containing the number of bytes read from the source file upon completion, * and a possible exception if IO operation was not completed successfully. + * + * @param f the file path to read from + * @param chunkSize the size of each read operation */ def fromPath(f: Path, chunkSize: Int): javadsl.Source[ByteString, CompletionStage[IOResult]] = new Source(scaladsl.FileIO.fromPath(f, chunkSize).toCompletionStage()) diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/FileIO.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/FileIO.scala index 69942f543d..00ebfe4a6d 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/FileIO.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/FileIO.scala @@ -51,7 +51,7 @@ object FileIO { * It materializes a [[Future]] of [[IOResult]] containing the number of bytes read from the source file upon completion, * and a possible exception if IO operation was not completed successfully. * - * @param f the file to read from + * @param f the file path to read from * @param chunkSize the size of each read operation, defaults to 8192 */ def fromPath(f: Path, chunkSize: Int = 8192): Source[ByteString, Future[IOResult]] = @@ -74,7 +74,7 @@ object FileIO { toPath(f.toPath, options) /** - * Creates a Sink which writes incoming [[ByteString]] elements to the given file. Overwrites existing files by default. + * Creates a Sink which writes incoming [[ByteString]] elements to the given file path. Overwrites existing files by default. * * Materializes a [[Future]] of [[IOResult]] that will be completed with the size of the file (in bytes) at the streams completion, * and a possible exception if IO operation was not completed successfully. @@ -82,7 +82,7 @@ object FileIO { * This source is backed by an Actor which will use the dedicated `akka.stream.blocking-io-dispatcher`, * unless configured otherwise by using [[ActorAttributes]]. * - * @param f the file to write to + * @param f the file path to write to * @param options File open options, defaults to Set(WRITE, CREATE) */ def toPath(f: Path, options: Set[StandardOpenOption] = Set(WRITE, CREATE)): Sink[ByteString, Future[IOResult]] =