Author: norman
Date: Fri Jan 14 19:12:59 2011
New Revision: 1059123

URL: http://svn.apache.org/viewvc?rev=1059123&view=rev
Log:
Some more small fixed 

Modified:
    
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
    
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
    
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/main/stream/ImapRequestStreamHandler.java
    
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
    
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java

Modified: 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
URL: 
http://svn.apache.org/viewvc/james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java?rev=1059123&r1=1059122&r2=1059123&view=diff
==============================================================================
--- 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
 (original)
+++ 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
 Fri Jan 14 19:12:59 2011
@@ -166,12 +166,10 @@ public class ImapRequestLineReader {
      * @throws DecodingException
      */
     public void consumeLine() throws DecodingException {
-        char next = nextChar();
-        while (next != '\n') {
+        while (isConsumed() == false) {
+            nextChar();
             consume();
-            next = nextChar();
         }
-        consume();
     }
     
     public String readContinuation() throws IOException {

Modified: 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
URL: 
http://svn.apache.org/viewvc/james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java?rev=1059123&r1=1059122&r2=1059123&view=diff
==============================================================================
--- 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
 (original)
+++ 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/decode/base/AbstractImapCommandParser.java
 Fri Jan 14 19:12:59 2011
@@ -355,7 +355,6 @@ public abstract class AbstractImapComman
 
         // Consume the '}' and the newline
         consumeChar(request, '}');
-        consumeCRLF(request);
 
         if (synchronizedLiteral) {
             request.commandContinuationRequest();
@@ -384,21 +383,6 @@ public abstract class AbstractImapComman
         }
     }
 
-    /**
-     * Consumes a CRLF from the request. 
-     * TODO: This is too liberal, the spec insists on \r\n for new lines.
-     * 
-     * @param request
-     * @throws DecodingException
-     */
-    private void consumeCRLF(ImapRequestLineReader request)
-            throws DecodingException {
-        char next = request.nextChar();
-        if (next != '\n') {
-            consumeChar(request, '\r');
-        }
-        consumeChar(request, '\n');
-    }
 
     /**
      * Consumes the next character in the request, checking that it matches the

Modified: 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/main/stream/ImapRequestStreamHandler.java
URL: 
http://svn.apache.org/viewvc/james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/main/stream/ImapRequestStreamHandler.java?rev=1059123&r1=1059122&r2=1059123&view=diff
==============================================================================
--- 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/main/stream/ImapRequestStreamHandler.java
 (original)
+++ 
james/imap/branches/nio-refactoring/message/src/main/java/org/apache/james/imap/main/stream/ImapRequestStreamHandler.java
 Fri Jan 14 19:12:59 2011
@@ -70,9 +70,7 @@ public final class ImapRequestStreamHand
             try {
 
                 BufferedReader reader = new BufferedReader(new 
InputStreamReader(input));
-                ImapRequestLineReader request = new 
ImapRequestLineReader((reader.readLine() + "\r\n").getBytes(), composer);
-
-                System.out.println(request.nextChar());
+                ImapRequestLineReader request = new 
ImapRequestLineReader((reader.readLine()).getBytes(), composer);
 
                 if (doProcessRequest(request, composer, session)) {
 
@@ -83,6 +81,7 @@ public final class ImapRequestStreamHand
                         // to clean up after a protocol error.
                         request.consumeLine();
                     } catch (DecodingException e) {
+                        e.printStackTrace();
                         // Cannot clean up. No recovery is therefore possible.
                         // Abandon connection.
                         if (logger.isInfoEnabled()) {
@@ -103,10 +102,14 @@ public final class ImapRequestStreamHand
 
                 return result;
             } catch (DecodingException e) {
+                e.printStackTrace();
+
                 logger.debug("Unexpected end of line. Cannot handle request: 
", e);
                 abandon(output, session);
                 return false;
             } catch (IOException e) {
+                e.printStackTrace();
+
                 logger.debug("Unexpected end of line. Cannot handle request: 
", e);
                 abandon(output, session);
                 return false;

Modified: 
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
URL: 
http://svn.apache.org/viewvc/james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java?rev=1059123&r1=1059122&r2=1059123&view=diff
==============================================================================
--- 
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
 (original)
+++ 
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserCharsetTest.java
 Fri Jan 14 19:12:59 2011
@@ -61,7 +61,7 @@ public class SearchCommandParserCharsetT
             NON_ASCII_SEARCH_TERM, UTF8);
 
     private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = NioUtils
-            .add(NioUtils.toBytes(" {16}\r\n", ASCII),
+            .add(NioUtils.toBytes(" {16}", ASCII),
                     BYTES_NON_ASCII_SEARCH_TERM);
 
     private static final byte[] CHARSET = NioUtils.toBytes("CHARSET UTF-8 ",

Modified: 
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
URL: 
http://svn.apache.org/viewvc/james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java?rev=1059123&r1=1059122&r2=1059123&view=diff
==============================================================================
--- 
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
 (original)
+++ 
james/imap/branches/nio-refactoring/message/src/test/java/org/apache/james/imap/decode/parser/SearchCommandParserQuotedCharsetTest.java
 Fri Jan 14 19:12:59 2011
@@ -19,9 +19,9 @@
 
 package org.apache.james.imap.decode.parser;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
-import java.io.ByteArrayInputStream;
 import java.nio.charset.Charset;
 import java.util.Collection;
 import java.util.HashSet;
@@ -35,7 +35,6 @@ import org.apache.james.imap.api.message
 import org.apache.james.imap.api.message.response.StatusResponse;
 import org.apache.james.imap.api.message.response.StatusResponseFactory;
 import org.apache.james.imap.api.process.ImapSession;
-import org.apache.james.imap.decode.ImapRequestLineReader;
 import org.apache.james.imap.decode.DecodingException;
 import org.apache.james.imap.decode.ImapRequestLineReader;
 import org.apache.james.imap.encode.MockImapResponseComposer;
@@ -121,7 +120,7 @@ public class SearchCommandParserQuotedCh
             NioUtils.toBytes("\"", ASCII));
 
     private static final byte[] BYTES_UTF8_NON_ASCII_SEARCH_TERM = add(NioUtils
-            .toBytes(" {16}\r\n", ASCII), BYTES_NON_ASCII_SEARCH_TERM);
+            .toBytes(" {16}", ASCII), BYTES_NON_ASCII_SEARCH_TERM);
 
     private static final byte[] CHARSET = NioUtils.toBytes("CHARSET UTF-8 ",
             ASCII);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to