Skip to content

Commit

Permalink
remove try catch statements
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsdant committed Sep 28, 2024
1 parent 1854d4b commit a247cba
Showing 1 changed file with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ class ClientQuotaMetadataManager(private[metadata] val quotaManagers: QuotaManag

private def handleIpQuota(ipEntity: QuotaEntity, quotaDelta: ClientQuotaDelta): Unit = {
val inetAddress = ipEntity match {
case IpEntity(ip) =>
try {
Some(InetAddress.getByName(ip))
} catch {
case _: UnknownHostException => throw new IllegalArgumentException(s"Unable to resolve address $ip")
}
case IpEntity(ip) => Some(InetAddress.getByName(ip))
case DefaultIpEntity => None
case _ => throw new IllegalStateException("Should only handle IP quota entities here")
}
Expand All @@ -123,11 +118,7 @@ class ClientQuotaMetadataManager(private[metadata] val quotaManagers: QuotaManag
if (!quotaName.equals(QuotaConfigs.IP_CONNECTION_RATE_OVERRIDE_CONFIG)) {
warn(s"Ignoring unexpected quota key $quotaName for entity $ipEntity")
} else {
try {
connectionQuotas.updateIpConnectionRateQuota(inetAddress, quotaValue.asScala.map(_.toInt))
} catch {
case t: Throwable => error(s"Failed to update IP quota $ipEntity", t)
}
connectionQuotas.updateIpConnectionRateQuota(inetAddress, quotaValue.asScala.map(_.toInt))
}
}
}
Expand Down Expand Up @@ -157,14 +148,10 @@ class ClientQuotaMetadataManager(private[metadata] val quotaManagers: QuotaManag
}

val quotaValue = newValue.map(new Quota(_, true))
try {
manager.updateQuota(
sanitizedUser = sanitizedUser,
clientId = sanitizedClientId.map(Sanitizer.desanitize),
sanitizedClientId = sanitizedClientId,
quota = quotaValue)
} catch {
case t: Throwable => error(s"Failed to update user-client quota $quotaEntity", t)
}
manager.updateQuota(
sanitizedUser = sanitizedUser,
clientId = sanitizedClientId.map(Sanitizer.desanitize),
sanitizedClientId = sanitizedClientId,
quota = quotaValue)
}
}

0 comments on commit a247cba

Please sign in to comment.