Charles I am using 1.2 and it is still causing the problem.
It also occurs on ordinary email, it affects pop dnloads and the
outgoing mail. The lack of <CRLF> on the end of a message with a not
empty final line causes the system to hang (only tested with netscape NT
client) when pop dnloading. I think this also may be contributing to the
file delete problems with NT. When a pop dnload is cancelled due to it
hanging, the file handle is still kept in the operation system
preventing the file from been deleted.

What appears to be the problem is that the CharTerminatedInputStream
class is consuming the <CRLF>.<CRLF> at the end of the message. It needs
to leave the the first <CRLF> or even the whole <CRLF>.<CRLF> at the
expense of an extra . in the message. I below is a solution I am
working on that does not consume the <CRLF>.<CRLF> I have not had a
chance to test it yet, you may want to try it though.

pb..


<code filename="CharTerminatedInputStream2.java">

package org.apache.james.util;

import java.io.InputStream;
import java.io.IOException;

/**
 * @version 1.0.0, 22/11/2000
 * @author  Federico Barbieri <[EMAIL PROTECTED]>
 * @author  Peter Blakeley <[EMAIL PROTECTED]>
 */
public class CharTerminatedInputStream2 
        extends InputStream {

    private InputStream in;
    private int match[];

    private int maxSize = -1;
    private int bytesRead = 0;
    private int read;
    private int readState = 0;
                
    public CharTerminatedInputStream2(InputStream in, char[] terminator)
{
        this(in, terminator, -1);
    }

    public CharTerminatedInputStream2(InputStream in, char[] terminator,
int maxSize) {
        match = new int[terminator.length];
        for (int i = 0; i < terminator.length; i++) {
            match[i] = (int)terminator[i];
        }
        this.in = in;
        this.maxSize = maxSize;
    }

    public int read() 
            throws IOException {
        
        read = read();
        if(read == -1) {
            return -1;
        }
        bytesRead++;

        // check to see if max message size is exceeded
        if(maxSize > -1 && bytesRead > maxSize) {
            throw new java.io.IOException(
                "Message too large!, bytesRead==" + bytesRead 
                + ", maxSize=="+maxSize);
        }

        if(readState == match.length) {
            read = -1;
        }else{        
            if((byte) read == match[readState]) {
                readState++;
            }else {
                if((byte) read == match[0]) {
                    readState = 1;
                }else{
                    readState = 0;
                }
            }
        }
        return read;
    }
}

</code>




Charles Benett wrote:
> 
> Which version of James are you using? I thought this had been fixed in
> 1.2.
> Charles
> 
> pb wrote:
> >
> > Charles I also have this problem only appears to be files with
> > attachments, I have an example but is 1meg plus let me know if you want
> > it. Adding a CRLF fixes the problem. #Note the problem only occures on
> > slow
> > connections, it dnloaded ok over the local network.
> >
> > Server System NT4 SP5
> > Client System W2k Netscape Comunicator ver 4.75
> >
> > pb...
> >
> > Charles Benett wrote:
> > >
> > > Hi, Simon
> > >
> > > Simon Klaiber wrote:
> > > >
> > > > Hi,
> > > > a couple of days ago i reported a bug that stopps the pop3 download (client
> > > > runs into a timout) when downloading some mails (other mails work properly.
> > > >
> > > > I now found out the difference between the mails that worked and those that
> > > > doesn't work:
> > > >
> > > > If the last line of the mail (stream store) is an empty line the mail works
> > > > If the last line is filled the mail jams the Pop3 port.
> > >
> > > I can't replicate this bug.
> > > What clients are you using? Can you send an example message that hangs
> > > them?
> > > charles
> > >
> > > ------------------------------------------------------------
> > > To subscribe:        [EMAIL PROTECTED]
> > > To unsubscribe:      [EMAIL PROTECTED]
> > > Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
> > > Problems?:           [EMAIL PROTECTED]
> > >
> > > .
> >
> > --
> >
> > 
>--------------------------------------------------------------------------------------
> > Peter Blakeley
> > JSP Servlets JINI RMI EJB Javaspaces XML
> > [ coolcat.com.au ]
> >
> > "Why open source? because I prefer to surf the wave to the beach rather
> > than swim all the way in."
> >
> > ------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
> > Problems?:           [EMAIL PROTECTED]
> 
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to