diff --git a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java index 8f6a3eac880..2a6502a86f7 100644 --- a/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java +++ b/jetty-http2/http2-common/src/main/java/org/eclipse/jetty/http2/generator/DataGenerator.java @@ -67,10 +67,11 @@ public class DataGenerator int end = data.limit(); for (int i = 1; i <= frames; ++i) { - data.limit(begin + Math.min(dataBytesPerFrame * i, length)); + int limit = begin + Math.min(dataBytesPerFrame * i, length); + data.limit(limit); ByteBuffer slice = data.slice(); - data.position(data.limit()); - generateFrame(lease, streamId, slice, i == frames && last); + data.position(limit); + generateFrame(lease, streamId, slice, i == frames && last && limit == end); } data.limit(end); }