My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 1397 attachment: dont-wait-for-smtp-server-banner-after-starttls-in-gerrit-2.3.patch (1.7 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java b/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java
index 7d7bc49..1f08a81 100644
--- a/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java
+++ b/gerrit-patch-commonsnet/src/main/java/org/apache/commons/net/smtp/AuthSMTPClient.java
@@ -18,7 +18,11 @@ import com.google.gerrit.util.ssl.BlindSSLSocketFactory;

import org.apache.commons.codec.binary.Base64;

+import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.SocketException;
import java.security.InvalidKeyException;
@@ -50,7 +54,22 @@ public class AuthSMTPClient extends SMTPClient {
}

_socket_ = sslFactory(verify).createSocket(_socket_, hostname, port, true);
- _connectAction_();
+
+ // XXX: Can't call _connectAction_() because SMTP server doesn't
+ // give banner information again after STARTTLS, thus SMTP._connectAction_()
+ // will wait on __getReply() forever, see source code of commons-net-2.2.
+ //
+ // The lines below are copied from SocketClient._connectAction_() and
+ // SMTP._connectAction_() in commons-net-2.2.
+ _socket_.setSoTimeout(_timeout_);
+ _input_ = _socket_.getInputStream();
+ _output_ = _socket_.getOutputStream();
+ _reader =
+ new BufferedReader(new InputStreamReader(_input_,
+ UTF_8));
+ _writer =
+ new BufferedWriter(new OutputStreamWriter(_output_,
+ UTF_8));
return true;
}

Powered by Google Project Hosting