wForget commented on PR #7760:
URL: https://github.com/apache/kyuubi/pull/7760#issuecomment-5793070893
Thanks for your contribution; I prefer handling exceptions within
`openSession`, like this:
```
override def openSession(
protocol: TProtocolVersion,
user: String,
password: String,
ipAddress: String,
conf: Map[String, String]): SessionHandle = {
val username = Option(user).filter(_.nonEmpty).getOrElse("anonymous")
limiter.foreach(_.increment(UserIpAddress(username, ipAddress)))
var handle: SessionHandle = null
try {
handle = super.openSession(protocol, username, password, ipAddress,
conf)
handle
} catch {
case e: Throwable =>
MetricsSystem.tracing { ms =>
ms.incCount(CONN_FAIL)
ms.incCount(MetricRegistry.name(CONN_FAIL, user))
ms.incCount(MetricRegistry.name(CONN_FAIL,
SessionType.INTERACTIVE.toString))
}
// If the session handle is null, closeSession(handle) will not be
called,
// so we need to decrement the limiter here.
if (handle == null) {
limiter.foreach(_.decrement(UserIpAddress(username, ipAddress)))
}
throw KyuubiSQLException(
s"Error opening session for $username client ip $ipAddress, due to
${e.getMessage}",
e)
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]