From bcf4de5b2cfb145cdf328de24c69330cfad3a982 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Mon, 24 Oct 2016 17:00:51 +0200 Subject: [PATCH] +str #20795 IOResult construction exposed, in bincompat way (#21070) * +str #20795 IOResult construction exposed, in bincompat way Thanks https://github.com/ktoso/kaze-class ;) * Addressed feedback in IOResult * Update IOResult.scala * Update IOResult.scala --- .../src/main/scala/akka/stream/IOResult.scala | 16 +++++++++++++++- project/MiMa.scala | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/akka-stream/src/main/scala/akka/stream/IOResult.scala b/akka-stream/src/main/scala/akka/stream/IOResult.scala index 9bf098b221..3d560dfafe 100644 --- a/akka-stream/src/main/scala/akka/stream/IOResult.scala +++ b/akka-stream/src/main/scala/akka/stream/IOResult.scala @@ -12,7 +12,10 @@ import scala.util.{ Failure, Success, Try } * @param count Numeric value depending on context, for example IO operations performed or bytes processed. * @param status Status of the result. Can be either [[akka.Done]] or an exception. */ -final case class IOResult private[stream] (count: Long, status: Try[Done]) { +final case class IOResult(count: Long, status: Try[Done]) { + + def withCount(value: Long): IOResult = copy(count = value) + def withStatus(value: Try[Done]): IOResult = copy(status = value) /** * Java API: Numeric value depending on context, for example IO operations performed or bytes processed. @@ -34,3 +37,14 @@ final case class IOResult private[stream] (count: Long, status: Try[Done]) { } } + +object IOResult { + + /** JAVA API: Creates successful IOResult */ + def createSuccessful(count: Long): IOResult = + new IOResult(count, Success(Done)) + + /** JAVA API: Creates failed IOResult, `count` should be the number of bytes (or other unit, please document in your APIs) processed before failing */ + def createFailed(count: Long, ex: Throwable): IOResult = + new IOResult(count, Failure(ex)) +} diff --git a/project/MiMa.scala b/project/MiMa.scala index 347fbc507b..2d82d710d3 100644 --- a/project/MiMa.scala +++ b/project/MiMa.scala @@ -998,6 +998,10 @@ object MiMa extends AutoPlugin { // #21330 takeWhile inclusive flag ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.stream.scaladsl.FlowOps.takeWhile") + ), + "2.4.11" -> Seq( + // #20795 IOResult construction exposed + ProblemFilters.exclude[MissingTypesProblem]("akka.stream.IOResult$") ) ) }