Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error reporting when during an authentication chain, the connection is closed by the remote server #187

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/main/java/io/vertx/ext/mail/impl/SMTPConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@ void init(Handler<String> initialReplyHandler) {

void handleNSException(Throwable t) {
if (!socketClosed && !shutdown) {
// shutdown() clear the handler, so gets a reference on the error handler first.
Handler<Throwable> handler;
synchronized (this) {
handler = errorHandler;
}
shutdown();
// some SMTP servers may not close the TCP connection gracefully
// https://github.com/vert-x3/vertx-mail-client/issues/175
if (quitSent) {
log.debug("got an exception on the netsocket after quit sent", t);
} else {
handleError(t);
handleError(t, handler);
}
} else {
log.debug("not returning follow-up exception", t);
Expand Down Expand Up @@ -294,6 +299,20 @@ private void handleError(Throwable t) {
});
}

private void handleError(Throwable t, Handler<Throwable> handler) {
context.emit(t, err -> {
if (handler != null) {
handler.handle(err);
} else {
if (log.isDebugEnabled()) {
log.error(t.getMessage(), t);
} else {
log.error(t.getMessage());
}
}
});
}

boolean isSsl() {
return ns.isSsl();
}
Expand Down