noel 2003/01/16 12:13:54
Modified: src/java/org/apache/james/smtpserver Tag: branch_2_1_fcs
SMTPHandler.java
Log:
Reverting to old version of readCommandLine due to spin loop defect
Revision Changes Path
No revision
No revision
1.35.4.3 +12 -27
jakarta-james/src/java/org/apache/james/smtpserver/SMTPHandler.java
Index: SMTPHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/smtpserver/SMTPHandler.java,v
retrieving revision 1.35.4.2
retrieving revision 1.35.4.3
diff -u -r1.35.4.2 -r1.35.4.3
--- SMTPHandler.java 13 Jan 2003 13:29:26 -0000 1.35.4.2
+++ SMTPHandler.java 16 Jan 2003 20:13:54 -0000 1.35.4.3
@@ -169,6 +169,11 @@
private PrintWriter out;
/**
+ * A Reader wrapper for the incoming stream of bytes coming from the socket.
+ */
+ private BufferedReader inReader;
+
+ /**
* The remote host name obtained by lookup on the socket.
*/
private String remoteHost;
@@ -279,6 +284,10 @@
handlerThread = Thread.currentThread();
}
in = new BufferedInputStream(socket.getInputStream(), 1024);
+ // An ASCII encoding can be used because all transmissions other
+ // that those in the DATA command are guaranteed
+ // to be ASCII
+ inReader = new BufferedReader(new InputStreamReader(in, "ASCII"), 512);
remoteIP = socket.getInetAddress().getHostAddress();
remoteHost = socket.getInetAddress().getHostName();
smtpID = random.nextInt(1024) + "";
@@ -382,6 +391,7 @@
clearResponseBuffer();
in = null;
+ inReader = null;
out = null;
remoteHost = null;
remoteIP = null;
@@ -470,31 +480,7 @@
* @throws IOException if an exception is generated reading in the input
characters
*/
final String readCommandLine() throws IOException {
- //Read through for \r or \n
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- byte b = -1;
- while (true) {
- b = (byte) in.read();
- if (b == 13) {
- //We're done, but we want to see if \n is next
- in.mark(1);
- b = (byte) in.read();
- if (b != 10) {
- in.reset();
- }
- break;
- } else if (b == 10) {
- //We're done
- break;
- } else if (b == -1) {
- break;
- }
- bout.write(b);
- }
- // An ASCII encoding can be used because all transmissions other
- // that those in the DATA command are guaranteed
- // to be ASCII
- return bout.toString("ASCII").trim();
+ return inReader.readLine().trim();
}
/**
@@ -1500,5 +1486,4 @@
}
}
-
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>