[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Classpathx-javamail] Problem with LineInputStream.readLine()
From: |
Xavier Poinsard |
Subject: |
[Classpathx-javamail] Problem with LineInputStream.readLine() |
Date: |
Thu, 30 Jun 2005 16:32:12 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050404) |
Hi,
I had a problem with POP3 retrieving of a message. After the "RETR 1"
commande, readline returns a string with only a LINE_FEED, but if
readline is called twice the second time it returns the correct answer.
To workaround this problem, I had to force (in the code) the char by
char read.
I attached a patch which may not be applied entirely since it contains
various things :
- check returns of readline to report End Of Stream
- possible offset bug fix in indexOfCRLF()
- javadoc for readline return
- my workaround
By the way, could you describe somewhere how to activate the logging ?
Thanks.
Xavier Poinsard
Index: gnu/inet/pop3/POP3Connection.java
===================================================================
RCS file: /cvsroot/classpath/inetlib/source/gnu/inet/pop3/POP3Connection.java,v
retrieving revision 1.19
diff -u -r1.19 POP3Connection.java
--- gnu/inet/pop3/POP3Connection.java 6 Jun 2005 21:00:25 -0000 1.19
+++ gnu/inet/pop3/POP3Connection.java 30 Jun 2005 14:20:26 -0000
@@ -770,6 +770,8 @@
throws IOException
{
response = in.readLine();
+ if (null==response)
+ throw new IOException("unexpected end of stream");
logger.log(POP3_TRACE, "< " + response);
if (response.indexOf(_OK) == 0)
{
Index: gnu/inet/util/CRLFInputStream.java
===================================================================
RCS file: /cvsroot/classpath/inetlib/source/gnu/inet/util/CRLFInputStream.java,v
retrieving revision 1.6
diff -u -r1.6 CRLFInputStream.java
--- gnu/inet/util/CRLFInputStream.java 6 Apr 2005 18:55:41 -0000 1.6
+++ gnu/inet/util/CRLFInputStream.java 30 Jun 2005 14:20:26 -0000
@@ -146,7 +146,7 @@
throws IOException
{
doReset = false;
- int lm1 = len - 1;
+ int lm1 = off+ len - 1;
for (int i = off; i < len; i++)
{
if (b[i] == CR)
Index: gnu/inet/util/LineInputStream.java
===================================================================
RCS file: /cvsroot/classpath/inetlib/source/gnu/inet/util/LineInputStream.java,v
retrieving revision 1.8
diff -u -r1.8 LineInputStream.java
--- gnu/inet/util/LineInputStream.java 7 Dec 2004 11:15:35 -0000 1.8
+++ gnu/inet/util/LineInputStream.java 30 Jun 2005 14:20:26 -0000
@@ -92,11 +92,12 @@
buf = new ByteArrayOutputStream();
this.encoding = encoding;
eof = false;
- blockReads = in.markSupported();
+ blockReads = false;//in.markSupported();
}
/**
* Read a line of input.
+ * @return the response as string or null if end of stream reached
*/
public String readLine()
throws IOException
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Classpathx-javamail] Problem with LineInputStream.readLine(),
Xavier Poinsard <=