commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1586800 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAP.java
Date Fri, 11 Apr 2014 23:52:51 GMT
Author: sebb
Date: Fri Apr 11 23:52:51 2014
New Revision: 1586800

URL: http://svn.apache.org/r1586800
Log:
NET-535 IMAP FETCH can overflow reply buffer; provide for partial responses
Add TRUE_CHUNK_LISTENER

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAP.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAP.java?rev=1586800&r1=1586799&r2=1586800&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAP.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAP.java Fri Apr 11
23:52:51 2014
@@ -79,6 +79,32 @@ public class IMAP extends SocketClient
         boolean chunkReceived(IMAP imap);
     }
 
+    /**
+     * <p>
+     * Implementation of IMAPChunkListener that returns {@code true}
+     * but otherwise does nothing.
+     * </p>
+     * <p>
+     * This is intended for use with a suitable ProtocolCommandListener.
+     * If the IMAP response contains multiple-line data, the protocol listener
+     * will be called for each multi-line chunk.
+     * The accumulated reply data will be cleared after calling the listener.
+     * If the response is very long, this can significantly reduce memory requirements.
+     * The listener will also start receiving response data earlier, as it does not have
+     * to wait for the entire response to be read.
+     * </p>
+     * <p>
+     * The ProtocolCommandListener must be prepared to accept partial responses.
+     * This should not be a problem for listeners that just log the input.
+     * </p>
+     * @see #setChunkListener(IMAPChunkListener)
+     */
+    public static final IMAPChunkListener TRUE_CHUNK_LISTENER = new IMAPChunkListener(){
+        public boolean chunkReceived(IMAP imap) {
+            return true;
+        }
+        
+    };
     private volatile IMAPChunkListener __chunkListener;
 
     private final char[] _initialID = { 'A', 'A', 'A', 'A' };
@@ -401,6 +427,7 @@ public class IMAP extends SocketClient
      * instances will be invoked with the partial response and a status of
      * {@link IMAPReply#PARTIAL} to indicate that the final reply code is not yet known.
      * @param listener the class to use, or {@code null} to disable
+     * @see #TRUE_CHUNK_LISTENER
      */
     public void setChunkListener(IMAPChunkListener listener) {
         __chunkListener = listener;



Mime
View raw message