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 no...@apache.org on 2010/04/18 20:14:31 UTC
svn commit: r935384 -
/james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/LineHandlerUpstreamHandler.java
Author: norman
Date: Sun Apr 18 18:14:31 2010
New Revision: 935384
URL: http://svn.apache.org/viewvc?rev=935384&view=rev
Log:
Revert changes.. not workin as it should..
Modified:
james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/LineHandlerUpstreamHandler.java
Modified: james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/LineHandlerUpstreamHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/LineHandlerUpstreamHandler.java?rev=935384&r1=935383&r2=935384&view=diff
==============================================================================
--- james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/LineHandlerUpstreamHandler.java (original)
+++ james/server/trunk/netty-socket/src/main/java/org/apache/james/socket/netty/LineHandlerUpstreamHandler.java Sun Apr 18 18:14:31 2010
@@ -21,7 +21,6 @@ package org.apache.james.socket.netty;
import org.apache.james.protocols.api.LineHandler;
import org.apache.james.protocols.api.ProtocolSession;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelUpstreamHandler;
@@ -45,15 +44,22 @@ public class LineHandlerUpstreamHandler<
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
Session pSession = (Session) attributes.get(ctx.getChannel());
- // Copy buffer and add CRLF to it
ChannelBuffer buf = (ChannelBuffer) e.getMessage();
- ChannelBuffer lineBuf = ChannelBuffers.buffer(buf.capacity() + 2);
- lineBuf.writeBytes(buf);
- lineBuf.writeInt('\r');
- lineBuf.writeInt('\n');
- byte[] lineBytes = new byte[lineBuf.capacity()];
- lineBuf.getBytes(0, lineBytes);
- handler.onLine(pSession, lineBytes);
+
+ byte[] line = new byte[buf.capacity()];
+ buf.getBytes(0, line);
+
+ // TODO: improve me!
+ // thats not the most performant thing but it at least works for now
+ // this should get improved later
+ byte[] newLine = new byte[line.length +2];
+ for (int i = 0; i < line.length; i++) {
+ newLine[i] = line[i];
+ }
+ newLine[newLine.length -2] = '\r';
+ newLine[newLine.length -1] = '\n';
+
+ handler.onLine(pSession,newLine);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org