setContent() — netty Function Reference
Architecture documentation for the setContent() function in AbstractDiskHttpData.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e668b0b0_6774_61ad_8797_72bf509862df["setContent()"] a3bc8afe_67a4_7958_deb1_2411299eac70["AbstractDiskHttpData"] e668b0b0_6774_61ad_8797_72bf509862df -->|defined in| a3bc8afe_67a4_7958_deb1_2411299eac70 style e668b0b0_6774_61ad_8797_72bf509862df fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java lines 104–149
@Override
public void setContent(ByteBuf buffer) throws IOException {
ObjectUtil.checkNotNull(buffer, "buffer");
try {
size = buffer.readableBytes();
checkSize(size);
if (definedSize > 0 && definedSize < size) {
throw new IOException("Out of size: " + size + " > " + definedSize);
}
if (file == null) {
file = tempFile();
}
if (buffer.readableBytes() == 0) {
// empty file
if (!file.createNewFile()) {
if (file.length() == 0) {
return;
} else {
if (!file.delete() || !file.createNewFile()) {
throw new IOException("file exists already: " + file);
}
}
}
return;
}
RandomAccessFile accessFile = new RandomAccessFile(file, "rw");
try {
accessFile.setLength(0);
FileChannel localfileChannel = accessFile.getChannel();
ByteBuffer byteBuffer = buffer.nioBuffer();
int written = 0;
while (written < size) {
written += localfileChannel.write(byteBuffer);
}
buffer.readerIndex(buffer.readerIndex() + written);
localfileChannel.force(false);
} finally {
accessFile.close();
}
setCompleted();
} finally {
// Release the buffer as it was retained before and we not need a reference to it at all
// See https://github.com/netty/netty/issues/1516
buffer.release();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does setContent() do?
setContent() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java.
Where is setContent() defined?
setContent() is defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/AbstractDiskHttpData.java at line 104.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free