GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Port 4.1: Honor maxAllocation for brotli in DelegatingDecompressorFra… · netty/netty@b5429bf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-http2/src
    • main/java/io/netty/handler/codec/http2
      • DelegatingDecompressorFrameListener.java
    • test/java/io/netty/handler/codec/http2
      • DataCompressionHttp2Test.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingDecompressorFrameListener.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ protected EmbeddedChannel newContentDecompressor(final ChannelHandlerContext ctx
183183
}
184184
if (Brotli.isAvailable() && BR.contentEqualsIgnoreCase(contentEncoding)) {
185185
return new EmbeddedChannel(ctx.channel().id(), ctx.channel().metadata().hasDisconnect(),
186-
ctx.channel().config(), new BrotliDecoder(maxAllocation));
186+
ctx.channel().config(), BrotliDecoder.newDecoderWithMaxAllocation(maxAllocation));
187187
}
188188
if (SNAPPY.contentEqualsIgnoreCase(contentEncoding)) {
189189
return new EmbeddedChannel(ctx.channel().id(), ctx.channel().metadata().hasDisconnect(),
Collapse file

‎codec-http2/src/test/java/io/netty/handler/codec/http2/DataCompressionHttp2Test.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/test/java/io/netty/handler/codec/http2/DataCompressionHttp2Test.java
+22-6Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,20 @@
5353
import java.io.ByteArrayOutputStream;
5454
import java.io.IOException;
5555
import java.net.InetSocketAddress;
56-
import java.nio.charset.StandardCharsets;
5756
import java.util.ArrayList;
5857
import java.util.List;
5958
import java.util.Random;
6059
import java.util.concurrent.Callable;
6160
import java.util.concurrent.CountDownLatch;
6261
import java.util.concurrent.atomic.AtomicReference;
63-
import java.util.function.BiConsumer;
64-
import java.util.stream.Stream;
6562

6663
import static io.netty.handler.codec.http2.Http2CodecUtil.DEFAULT_PRIORITY_WEIGHT;
6764
import static io.netty.handler.codec.http2.Http2TestUtil.runInChannel;
6865
import static java.util.concurrent.TimeUnit.MILLISECONDS;
6966
import static java.util.concurrent.TimeUnit.SECONDS;
7067
import static org.assertj.core.api.Assertions.assertThat;
7168
import static org.junit.jupiter.api.Assertions.assertEquals;
72-
import static org.junit.jupiter.api.Assertions.assertNotNull;
7369
import static org.junit.jupiter.api.Assertions.assertTrue;
74-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
7570
import static org.mockito.Mockito.any;
7671
import static org.mockito.Mockito.anyBoolean;
7772
import static org.mockito.Mockito.anyInt;
@@ -286,8 +281,29 @@ public Void call() throws Exception {
286281
});
287282
}
288283

284+
@ParameterizedTest
285+
@ValueSource(ints = {0, 10})
286+
public void brotliEncodingHonorsMaxAllocation(final int padding) throws Exception {
287+
// Use a maxAllocation well below the default output buffer size of the BrotliDecoder (64 KiB).
288+
final byte[] text = new byte[128 * 1024];
289+
for (int i = 0; i < text.length; i++) {
290+
text[i] = (byte) (i % 251);
291+
}
292+
maxAllocation = 1024;
293+
294+
testEncodingMessage(padding, text, HttpHeaderValues.BR, new Callable<Void>() {
295+
@Override
296+
public Void call() throws Exception {
297+
awaitServer();
298+
assertThat(serverOut.toByteArray()).isEqualTo(text);
299+
assertThat(maxServerOutBufferSize).isLessThanOrEqualTo(maxAllocation);
300+
return null;
301+
}
302+
});
303+
}
304+
289305
private void testEncodingMessage(final int padding, final String text, AsciiString compressionAlgorithmName)
290-
throws Exception {
306+
throws Exception {
291307
testEncodingMessage(padding, text, compressionAlgorithmName, new Callable<Void>() {
292308
@Override
293309
public Void call() throws Exception {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.