noel        2004/05/21 20:55:03

  Modified:    src/java/org/apache/james/util Tag: branch_2_1_fcs
                        CharTerminatedInputStream.java
  Log:
  Fix JAMES-282.  If the stream closes before the terminator is seen, throw an 
Exception, since returning -1 (end of stream) is the NORMAL return when the terminator 
is encountered.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.2.4.4   +3 -3      
james-server/src/java/org/apache/james/util/CharTerminatedInputStream.java
  
  Index: CharTerminatedInputStream.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/util/CharTerminatedInputStream.java,v
  retrieving revision 1.2.4.3
  retrieving revision 1.2.4.4
  diff -u -r1.2.4.3 -r1.2.4.4
  --- CharTerminatedInputStream.java    15 Mar 2004 03:54:22 -0000      1.2.4.3
  +++ CharTerminatedInputStream.java    22 May 2004 03:55:03 -0000      1.2.4.4
  @@ -86,6 +86,7 @@
        *
        * @return the byte read off the stream
        * @throws IOException if an IOException is encountered while reading off the 
stream
  +     * @throws ProtocolException if the underlying stream returns -1 before the 
terminator is seen.
        */
       public int read() throws IOException {
           if (endFound) {
  @@ -96,9 +97,8 @@
               //We have no data... read in a record
               int b = in.read();
               if (b == -1) {
  -                //End of stream reached
  -                endFound = true;
  -                return -1;
  +                //End of stream reached without seeing the terminator
  +                throw new java.net.ProtocolException("pre-mature end of data");
               }
               if (b != match[0]) {
                   //this char is not the first char of the match
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to