commonNotBadReleaseBuffersDuringDecoding() — netty Function Reference
Architecture documentation for the commonNotBadReleaseBuffersDuringDecoding() function in HttpPostMultiPartRequestDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 414441c4_b377_7258_e839_7d69f38ccd85["commonNotBadReleaseBuffersDuringDecoding()"] 8ca6727e_4177_9097_12de_7bccb17e5dea["HttpPostMultiPartRequestDecoderTest"] 414441c4_b377_7258_e839_7d69f38ccd85 -->|defined in| 8ca6727e_4177_9097_12de_7bccb17e5dea a54bad25_e7e4_dc37_0fd4_58d812cd26f4["testNotBadReleaseBuffersDuringDecodingDiskFactory()"] a54bad25_e7e4_dc37_0fd4_58d812cd26f4 -->|calls| 414441c4_b377_7258_e839_7d69f38ccd85 df98f65c_044f_e2d6_7fb4_338cec6f7840["testNotBadReleaseBuffersDuringDecodingMemoryFactory()"] df98f65c_044f_e2d6_7fb4_338cec6f7840 -->|calls| 414441c4_b377_7258_e839_7d69f38ccd85 12ff4d2f_2755_6741_83da_810e2b5369a0["testNotBadReleaseBuffersDuringDecodingMixedFactory()"] 12ff4d2f_2755_6741_83da_810e2b5369a0 -->|calls| 414441c4_b377_7258_e839_7d69f38ccd85 style 414441c4_b377_7258_e839_7d69f38ccd85 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java lines 322–390
private static void commonNotBadReleaseBuffersDuringDecoding(HttpDataFactory factory, boolean inMemory)
throws IOException {
int nbItems = 20;
int bytesPerItem = 1000;
int maxMemory = 500;
String prefix1 = "\n--861fbeab-cd20-470c-9609-d40a0f704466\n" +
"Content-Disposition: form-data; name=\"image";
String prefix2 =
"\"; filename=\"guangzhou.jpeg\"\n" +
"Content-Type: image/jpeg\n" +
"Content-Length: " + bytesPerItem + "\n" + "\n";
String suffix = "\n--861fbeab-cd20-470c-9609-d40a0f704466--\n";
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/upload");
request.headers().set("content-type", "multipart/form-data; boundary=861fbeab-cd20-470c-9609-d40a0f704466");
request.headers().set("content-length", nbItems * (prefix1.length() + prefix2.length() + 2 + bytesPerItem)
+ suffix.length());
HttpPostMultipartRequestDecoder decoder = new HttpPostMultipartRequestDecoder(factory, request);
decoder.setDiscardThreshold(maxMemory);
for (int rank = 0; rank < nbItems; rank++) {
byte[] bp1 = prefix1.getBytes(CharsetUtil.UTF_8);
byte[] bp2 = prefix2.getBytes(CharsetUtil.UTF_8);
byte[] prefix = new byte[bp1.length + 2 + bp2.length];
for (int i = 0; i < bp1.length; i++) {
prefix[i] = bp1[i];
}
byte[] brank = Integer.toString(10 + rank).getBytes(CharsetUtil.UTF_8);
prefix[bp1.length] = brank[0];
prefix[bp1.length + 1] = brank[1];
for (int i = 0; i < bp2.length; i++) {
prefix[bp1.length + 2 + i] = bp2[i];
}
ByteBuf buf = Unpooled.wrappedBuffer(prefix);
DefaultHttpContent httpContent = new DefaultHttpContent(buf);
decoder.offer(httpContent);
httpContent.release();
byte[] body = new byte[bytesPerItem];
Arrays.fill(body, (byte) rank);
ByteBuf content = Unpooled.wrappedBuffer(body, 0, bytesPerItem);
httpContent = new DefaultHttpContent(content);
decoder.offer(httpContent);
httpContent.release();
}
byte[] lastbody = suffix.getBytes(CharsetUtil.UTF_8);
ByteBuf content2 = Unpooled.wrappedBuffer(lastbody, 0, lastbody.length);
DefaultHttpContent httpContent = new DefaultHttpContent(content2);
decoder.offer(httpContent);
httpContent.release();
decoder.offer(new DefaultLastHttpContent());
for (int rank = 0; rank < nbItems; rank++) {
FileUpload data = (FileUpload) decoder.getBodyHttpData("image" + (10 + rank));
assertEquals(bytesPerItem, data.length());
assertEquals(inMemory, data.isInMemory());
byte[] body = new byte[bytesPerItem];
Arrays.fill(body, (byte) rank);
assertTrue(Arrays.equals(body, data.get()));
}
// To not be done since will load full file on memory: assertEquals(data.get().length, fileSize);
// Not mandatory since implicitly called during destroy of decoder
for (InterfaceHttpData httpData: decoder.getBodyHttpDatas()) {
httpData.release();
factory.removeHttpDataFromClean(request, httpData);
}
factory.cleanAllHttpData();
decoder.destroy();
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does commonNotBadReleaseBuffersDuringDecoding() do?
commonNotBadReleaseBuffersDuringDecoding() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java.
Where is commonNotBadReleaseBuffersDuringDecoding() defined?
commonNotBadReleaseBuffersDuringDecoding() is defined in codec-http/src/test/java/io/netty/handler/codec/http/multipart/HttpPostMultiPartRequestDecoderTest.java at line 322.
What calls commonNotBadReleaseBuffersDuringDecoding()?
commonNotBadReleaseBuffersDuringDecoding() is called by 3 function(s): testNotBadReleaseBuffersDuringDecodingDiskFactory, testNotBadReleaseBuffersDuringDecodingMemoryFactory, testNotBadReleaseBuffersDuringDecodingMixedFactory.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free