From 2c32a7cde9b08d610a6594d96306512fc49488b5 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Sat, 19 Nov 2016 13:43:39 +0100 Subject: [PATCH] !str #21395 move compression default values used in public API into public place Would it otherwise have even worked for non-akka users? --- .../stream/impl/io/compression/DeflateDecompressor.scala | 5 +---- .../impl/io/compression/DeflateDecompressorBase.scala | 6 ++---- .../akka/stream/impl/io/compression/GzipDecompressor.scala | 2 +- .../src/main/scala/akka/stream/scaladsl/Compression.scala | 6 ++++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala index 85ab296f61a..19374e303dd 100644 --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala @@ -6,12 +6,9 @@ package akka.stream.impl.io.compression import java.util.zip.Inflater import akka.stream.Attributes -import akka.stream.impl.io.ByteStringParser -import akka.stream.impl.io.ByteStringParser.{ ParseResult, ParseStep } -import akka.util.ByteString /** INTERNAL API */ -private[akka] class DeflateDecompressor(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault) +private[akka] class DeflateDecompressor(maxBytesPerChunk: Int) extends DeflateDecompressorBase(maxBytesPerChunk) { override def createLogic(attr: Attributes) = new DecompressorParsingLogic { diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressorBase.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressorBase.scala index a0f4590e580..e8d4775ba0f 100644 --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressorBase.scala +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressorBase.scala @@ -10,7 +10,7 @@ import akka.stream.impl.io.ByteStringParser.{ ParseResult, ParseStep } import akka.util.ByteString /** INTERNAL API */ -private[akka] abstract class DeflateDecompressorBase(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault) +private[akka] abstract class DeflateDecompressorBase(maxBytesPerChunk: Int) extends ByteStringParser[ByteString] { abstract class DecompressorParsingLogic extends ParsingLogic { @@ -45,6 +45,4 @@ private[akka] abstract class DeflateDecompressorBase(maxBytesPerChunk: Int = Def } /** INTERNAL API */ -private[akka] object DeflateDecompressorBase { - final val MaxBytesPerChunkDefault = 64 * 1024 -} +private[akka] object DeflateDecompressorBase \ No newline at end of file diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipDecompressor.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipDecompressor.scala index 87e2d3dcac0..0f92eb78f48 100644 --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipDecompressor.scala +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipDecompressor.scala @@ -11,7 +11,7 @@ import akka.stream.impl.io.ByteStringParser.{ ParseResult, ParseStep } import akka.util.ByteString /** INTERNAL API */ -private[akka] class GzipDecompressor(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault) +private[akka] class GzipDecompressor(maxBytesPerChunk: Int) extends DeflateDecompressorBase(maxBytesPerChunk) { override def createLogic(attr: Attributes) = new DecompressorParsingLogic { diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala index e7e77821cd0..c47c00256aa 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala @@ -8,6 +8,8 @@ import akka.stream.impl.io.compression._ import akka.util.ByteString object Compression { + final val MaxBytesPerChunkDefault = 64 * 1024 + /** * Creates a flow that gzip-compresses a stream of ByteStrings. Note that the compressor * will SYNC_FLUSH after every [[ByteString]] so that it is guaranteed that every [[ByteString]] @@ -24,7 +26,7 @@ object Compression { * * @param maxBytesPerChunk Maximum length of an output [[ByteString]] chunk. */ - def gunzip(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] = + def gunzip(maxBytesPerChunk: Int = MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] = Flow[ByteString].via(new GzipDecompressor(maxBytesPerChunk)) .named("gunzip") @@ -44,7 +46,7 @@ object Compression { * * @param maxBytesPerChunk Maximum length of an output [[ByteString]] chunk. */ - def inflate(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] = + def inflate(maxBytesPerChunk: Int = MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] = Flow[ByteString].via(new DeflateDecompressor(maxBytesPerChunk)) .named("inflate") }