Skip to content

Commit 6f7c7e2

Browse files
committed
fix: Address gemini review
1 parent ecc7f2b commit 6f7c7e2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/java/com/google/firebase/internal/ApacheHttp2AsyncEntityConsumer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ public void updateCapacity(CapacityChannel capacityChannel) throws IOException {
4949

5050
@Override
5151
public void consume(ByteBuffer src) throws IOException {
52-
byte[] bytes = new byte[src.remaining()];
53-
src.get(bytes);
54-
buffer.write(bytes);
52+
if (src.hasArray()) {
53+
buffer.write(src.array(), src.arrayOffset() + src.position(), src.remaining());
54+
src.position(src.limit());
55+
} else {
56+
byte[] bytes = new byte[src.remaining()];
57+
src.get(bytes);
58+
buffer.write(bytes);
59+
}
5560
}
5661

5762
@Override

src/test/java/com/google/firebase/internal/ApacheHttp2TransportTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,8 @@ public void handle(
376376

377377
boolean wasAutoDecompressed = response.getContentEncoding() == null;
378378
if (wasAutoDecompressed) {
379-
System.out.println("Auto-decompressed");
380379
assertEquals(originalContent.length(), response.getContentLength());
381380
} else {
382-
System.out.println("Not auto-decompressed");
383381
assertEquals("gzip", response.getContentEncoding());
384382
assertEquals(gzippedContent.length, response.getContentLength());
385383
}

0 commit comments

Comments
 (0)