commits@javamail.java.net

[mercurial:139] Fail POP3Folder.open if STAT command fails.

From: <shannon_at_kenai.com>
Date: Fri, 8 May 2009 20:35:40 +0000 (GMT)

Repository: mercurial
Revision: 139
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2009-05-07 00:24:45 UTC
Link:
http://kenai.com/projects/javamail/sources/mercurial/revision/139

Log Message:
-----------
Fail POP3Folder.open if STAT command fails.

Modified Paths:
--------------
    doc/release/CHANGES.txt
    mail/src/main/java/com/sun/mail/pop3/Protocol.java

Diffs:
-----
diff -r 77e63f5e61ba -r a498a1edfe98 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Wed May 06 16:44:46 2009 -0700
+++ b/doc/release/CHANGES.txt Wed May 06 17:24:45 2009 -0700
@@ -16,6 +16,7 @@
 <no id> add starttls support to POP3
 <no id> fix deadlock in IMAP IDLE support
 <no id> add mail.transport.protocol.<address-type> property
+<no id> fail POP3Folder.open if STAT command fails
 
 
                  CHANGES IN THE 1.4.2 RELEASE
diff -r 77e63f5e61ba -r a498a1edfe98
mail/src/main/java/com/sun/mail/pop3/Protocol.java
--- a/mail/src/main/java/com/sun/mail/pop3/Protocol.java Wed May
06 16:44:46 2009 -0700
+++ b/mail/src/main/java/com/sun/mail/pop3/Protocol.java Wed May
06 17:24:45 2009 -0700
@@ -280,7 +280,19 @@
     synchronized Status stat() throws IOException {
        Response r = simpleCommand("STAT");
        Status s = new Status();
- if (r.ok && r.data != null) {
+
+ /*
+ * Normally the STAT command shouldn't fail but apparently it
+ * does when accessing Hotmail too often, returning:
+ * -ERR login allowed only every 15 minutes
+ * (Why it doesn't just fail the login, I don't know.)
+ * This is a serious failure that we don't want to hide
+ * from the user.
+ */
+ if (!r.ok)
+ throw new IOException("STAT command failed: " + r.data);
+
+ if (r.data != null) {
            try {
                StringTokenizer st = new StringTokenizer(r.data);
                s.total = Integer.parseInt(st.nextToken());