diff --git a/avaje-jex/src/main/java/io/avaje/jex/compression/CompressedOutputStream.java b/avaje-jex/src/main/java/io/avaje/jex/compression/CompressedOutputStream.java index a067c21d..cdbdb9d5 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/compression/CompressedOutputStream.java +++ b/avaje-jex/src/main/java/io/avaje/jex/compression/CompressedOutputStream.java @@ -12,13 +12,13 @@ * OutputStream implementation that conditionally compresses the output based on configuration and * request headers. */ -public class CompressedOutputStream extends OutputStream { +public final class CompressedOutputStream extends OutputStream { private final int minSizeForCompression; private final CompressionConfig compression; private final Context ctx; - private final OutputStream originStream; + private OutputStream compressedStream; private boolean compressionDecided; @@ -33,9 +33,7 @@ public CompressedOutputStream( private void decideCompression(int length) throws IOException { if (!compressionDecided) { var encoding = ctx.responseHeader(Constants.CONTENT_ENCODING); - if (encoding != null) { - this.compressedStream = findMatchingCompressor(encoding) .orElseThrow( @@ -81,9 +79,7 @@ public void close() throws IOException { } private Optional findMatchingCompressor(String acceptedEncoding) { - if (acceptedEncoding != null) { - return Arrays.stream(acceptedEncoding.split(",")).map(compression::forType).findFirst(); } return Optional.empty(); diff --git a/avaje-jex/src/main/java/io/avaje/jex/compression/GzipCompressor.java b/avaje-jex/src/main/java/io/avaje/jex/compression/GzipCompressor.java index c3945dc4..52778950 100644 --- a/avaje-jex/src/main/java/io/avaje/jex/compression/GzipCompressor.java +++ b/avaje-jex/src/main/java/io/avaje/jex/compression/GzipCompressor.java @@ -29,9 +29,9 @@ public OutputStream compress(OutputStream out) throws IOException { return new LeveledGzipStream(out, level); } - static class LeveledGzipStream extends GZIPOutputStream { + private static final class LeveledGzipStream extends GZIPOutputStream { - public LeveledGzipStream(OutputStream out, int level) throws IOException { + private LeveledGzipStream(OutputStream out, int level) throws IOException { super(out); this.def.setLevel(level); }