geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1704974 - in /geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail: transport/smtp/SMTPConnection.java util/TraceInputStream.java util/TraceOutputStream.java
Date Thu, 24 Sep 2015 02:13:31 GMT
Author: rmannibucau
Date: Thu Sep 24 02:13:31 2015
New Revision: 1704974

URL: http://svn.apache.org/viewvc?rev=1704974&view=rev
Log:
GERONIMO-6547 ensure smtp socket accesses are appropriate even for bad servers

Modified:
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/smtp/SMTPConnection.java
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceInputStream.java
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceOutputStream.java

Modified: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/smtp/SMTPConnection.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/smtp/SMTPConnection.java?rev=1704974&r1=1704973&r2=1704974&view=diff
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/smtp/SMTPConnection.java
(original)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/smtp/SMTPConnection.java
Thu Sep 24 02:13:31 2015
@@ -542,6 +542,7 @@ public class SMTPConnection extends Mail
             mimeOut.writeSMTPTerminator();
             // and flush the data to send it along
             mimeOut.flush();
+            this.outputStream.flush(); // most of the time MIMEOutputStream#flush does nothing
so ensure we actually flush the data
         } catch (IOException e) {
             throw new MessagingException(e.toString());
         } catch (MessagingException e) {
@@ -667,10 +668,8 @@ public class SMTPConnection extends Mail
         if (socket == null || !socket.isConnected()) {
             throw new MessagingException("no connection");
         }
-        try {
-            outputStream.write(data.getBytes("ISO8859-1"));
-            outputStream.write(CR);
-            outputStream.write(LF);
+        try { // don't write it in multiple times, ie build the data + "\r\n" string in memory
to not get surprises on servers read() side
+            outputStream.write((data + "\r\n").getBytes("ISO8859-1"));
             outputStream.flush();
         } catch (IOException e) {
             throw new MessagingException(e.toString());

Modified: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceInputStream.java?rev=1704974&r1=1704973&r2=1704974&view=diff
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceInputStream.java
(original)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceInputStream.java
Thu Sep 24 02:13:31 2015
@@ -99,4 +99,12 @@ public class TraceInputStream extends Fi
         }
         return b;
     }
+
+    public int read(byte[] b) throws IOException {
+        final int read = in.read(b);
+        if (debug && read > 0) {
+            traceStream.write(b, 0, read);
+        }
+        return read;
+    }
 }

Modified: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceOutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceOutputStream.java?rev=1704974&r1=1704973&r2=1704974&view=diff
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceOutputStream.java
(original)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/TraceOutputStream.java
Thu Sep 24 02:13:31 2015
@@ -80,4 +80,18 @@ public class TraceOutputStream extends F
         }
         super.write(b);
     }
+
+    public void write(byte[] b, int off, int len) throws IOException {
+        if (this.debug) {
+            this.traceStream.write(b, off, len);
+        }
+        out.write(b, off, len);
+    }
+
+    public void write(byte[] b) throws IOException {
+        if (this.debug) {
+            this.traceStream.write(b);
+        }
+        out.write(b);
+    } 
 }



Mime
View raw message