[ 
http://issues.apache.org/jira/browse/DIRMINA-201?page=comments#action_12373151 
] 

Niklas Therning commented on DIRMINA-201:
-----------------------------------------

When I implemented the server part of an SMTP-server I actually decided not to 
use CPD nor the ProtocolCodecFilter just because of this issue. IMO, a problem 
with the how the decoder works is that it first decodes as many messages as 
possible from the accumulated buffer and then forwards all of them to the next 
filter. This isn't very efficient if you want to pass a slice of the received 
buffer to the next filter because it would require you to copy it. It would be 
better if SimpleProtocolDecoderOutput.write() passed messages to the next 
filter right away instead of queueing them. That would solve your problem. The 
only downside I can think of is that this wouldn't work if you use a 
ThreadPoolFilter after your ProtocolCodecFilter. I don't think that is very 
common though.

IMO a fix wouldn't have to include changes to CPD and SocketIoProcessor. If 
only SimpleProtocolDecoderOutput would be changed to not queue messages but 
forward them right away I think this wouldn't be an issue. Please correct me if 
I'm wrong. Maybe ProtocolCodecFilter could be refactored to allow for a custom 
ProtocolDecoderOutput to be used?

The filter I implemented would be another solution. It's very simple. It does 
exactly what CPD does but it doesn't use a ProtocolDecoderOutput. It can also 
be put into "data mode" which means that all received data will be forwarded 
untouched without any copying. It's a really nice feature when you have 
protocols which both include line based command and raw data (like SMTP). I 
wouldn't mind adding it to MINA if it's of any interest.

> Make the CumulativeProtocolDecoder "slice compatible"
> -----------------------------------------------------
>
>          Key: DIRMINA-201
>          URL: http://issues.apache.org/jira/browse/DIRMINA-201
>      Project: Directory MINA
>         Type: Improvement

>     Versions: 0.9.3
>     Reporter: Robert Greig
>  Attachments: CumulativeProtocolDecoder.java, CumulativeProtocolDecoder.java, 
> CumulativeProtocolDecoder.java.diff, SocketIoProcessor.java, 
> SocketIoProcessor.java.diff
>
> There is a problem with using slice() along with the 
> CumulativeProtocolDecoder. 
> The problem is that the CPD does a compact() when it has completed the 
> attempt to decode the buffer, and then reuses the buffer.
> If your decoder expects to be able to take a slice() of the buffer and use 
> that it will find the data gets corrupted by the next call to the 
> CumulativeProtocolDecoder.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to