You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2019/11/12 21:37:36 UTC
[james-project] 14/15: [Refactoring] avoid building many times the
same buffer
This is an automated email from the ASF dual-hosted git repository.
matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 598b3c4bd5f1bb03b56d7d930ba379344acd0815
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Fri Nov 8 18:17:32 2019 +0100
[Refactoring] avoid building many times the same buffer
---
.../org/apache/james/imapserver/netty/ImapHeartbeatHandler.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapHeartbeatHandler.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapHeartbeatHandler.java
index 29e085e..4d05da2 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapHeartbeatHandler.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapHeartbeatHandler.java
@@ -20,6 +20,7 @@ package org.apache.james.imapserver.netty;
import java.nio.charset.StandardCharsets;
+import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.timeout.IdleState;
@@ -28,10 +29,14 @@ import org.jboss.netty.handler.timeout.IdleStateEvent;
public class ImapHeartbeatHandler extends IdleStateAwareChannelHandler {
+ private static final ChannelBuffer HEARTBEAT_BUFFER = ChannelBuffers
+ .unmodifiableBuffer(
+ ChannelBuffers.wrappedBuffer("* OK Hang in there..\r\n".getBytes(StandardCharsets.US_ASCII)));
+
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
if (e.getState().equals(IdleState.WRITER_IDLE)) {
- e.getChannel().write(ChannelBuffers.wrappedBuffer("* OK Hang in there..\r\n".getBytes(StandardCharsets.US_ASCII)));
+ e.getChannel().write(HEARTBEAT_BUFFER);
}
super.channelIdle(ctx, e);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org