@@ -189,8 +189,7 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
189189 LOG_INFO (cnxString_ << " Create ClientConnection, timeout=" << clientConfiguration.getConnectionTimeout ());
190190 if (!authentication_) {
191191 LOG_ERROR (" Invalid authentication plugin" );
192- close (ResultAuthenticationError, false );
193- return ;
192+ throw ResultException{ResultAuthenticationError};
194193 }
195194 if (clientConfiguration.isUseTls ()) {
196195#if BOOST_VERSION >= 105400
@@ -212,8 +211,7 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
212211 ctx.load_verify_file (trustCertFilePath);
213212 } else {
214213 LOG_ERROR (trustCertFilePath << " : No such trustCertFile" );
215- close (ResultAuthenticationError, false );
216- return ;
214+ throw ResultException{ResultAuthenticationError};
217215 }
218216 } else {
219217 ctx.set_default_verify_paths ();
@@ -230,13 +228,11 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
230228 tlsPrivateKey = authData->getTlsPrivateKey ();
231229 if (!file_exists (tlsCertificates)) {
232230 LOG_ERROR (tlsCertificates << " : No such tlsCertificates" );
233- close (ResultAuthenticationError, false );
234- return ;
231+ throw ResultException{ResultAuthenticationError};
235232 }
236233 if (!file_exists (tlsCertificates)) {
237234 LOG_ERROR (tlsCertificates << " : No such tlsCertificates" );
238- close (ResultAuthenticationError, false );
239- return ;
235+ throw ResultException{ResultAuthenticationError};
240236 }
241237 ctx.use_private_key_file (tlsPrivateKey, boost::asio::ssl::context::pem);
242238 ctx.use_certificate_file (tlsCertificates, boost::asio::ssl::context::pem);
@@ -1259,13 +1255,7 @@ void ClientConnection::handleConsumerStatsTimeout(const boost::system::error_cod
12591255 startConsumerStatsTimer (consumerStatsRequests);
12601256}
12611257
1262- void ClientConnection::close (Result result, bool constructCompleted) {
1263- if (!constructCompleted) {
1264- state_ = Disconnected;
1265- connectPromise_.setFailed (result);
1266- return ;
1267- }
1268-
1258+ void ClientConnection::close (Result result) {
12691259 Lock lock (mutex_);
12701260 if (isClosed ()) {
12711261 return ;
0 commit comments