You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/05/09 01:35:39 UTC
[james-project] 09/09: JAMES-3737 Backport resetReaderIndex fix
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 169d83405ec8da1070542822c73a4f2da988b1fe
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu May 5 18:27:41 2022 +0700
JAMES-3737 Backport resetReaderIndex fix
---
.../apache/james/imapserver/netty/ImapRequestFrameDecoder.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
index fc51b68c97..9cd437eaf9 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
@@ -103,7 +103,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
Map<String, Object> attachment = ctx.channel().attr(FRAME_DECODE_ATTACHMENT_ATTRIBUTE_KEY).get();
- Pair<ImapRequestLineReader, Integer> readerAndSize = obtainReader(ctx, in, attachment);
+ Pair<ImapRequestLineReader, Integer> readerAndSize = obtainReader(ctx, in, attachment, readerIndex);
if (readerAndSize == null) {
return;
}
@@ -161,7 +161,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
in.readerIndex(readerIndex);
}
- private Pair<ImapRequestLineReader, Integer> obtainReader(ChannelHandlerContext ctx, ByteBuf in, Map<String, Object> attachment) throws IOException {
+ private Pair<ImapRequestLineReader, Integer> obtainReader(ChannelHandlerContext ctx, ByteBuf in, Map<String, Object> attachment, int readerIndex) throws IOException {
boolean retry = false;
ImapRequestLineReader reader;
// check if we failed before and if we already know how much data we
@@ -180,7 +180,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
// ok seems like it will not fit in the memory limit so we
// need to store it in a temporary file
- uploadToAFile(ctx, in, attachment, size);
+ uploadToAFile(ctx, in, attachment, size, readerIndex);
return null;
} else {
@@ -198,7 +198,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
return Pair.of(reader, size);
}
- private void uploadToAFile(ChannelHandlerContext ctx, ByteBuf in, Map<String, Object> attachment, int size) throws IOException {
+ private void uploadToAFile(ChannelHandlerContext ctx, ByteBuf in, Map<String, Object> attachment, int size, int readerIndex) throws IOException {
final File f;
Sinks.Many<byte[]> sink;
@@ -244,7 +244,7 @@ public class ImapRequestFrameDecoder extends ByteToMessageDecoder implements Net
ImapRequestLineReader reader = new NettyStreamImapRequestLineReader(ctx.channel(), f, RETRY);
try {
- parseImapMessage(ctx, null, attachment, Pair.of(reader, written.get()))
+ parseImapMessage(ctx, null, attachment, Pair.of(reader, written.get()), readerIndex)
.ifPresent(ctx::fireChannelRead);
} catch (DecodingException e) {
ctx.fireExceptionCaught(e);
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org