From 0fb845e81a7a942fda59469ebbb5cdb8928bb374 Mon Sep 17 00:00:00 2001 From: jianglai Date: Thu, 17 May 2018 10:50:53 -0700 Subject: [PATCH] Remove no quota leased warning from quota handler inactive callback When EPP SSL handshake is unsuccessful, #channelInactive is called but there are no quotas to return, because quotas are only leased upon the first #channelRead. There is no need to log a warning and throw an exception in this case because the handshake exception would have been thrown already. Throwing a second exception just crowds the log. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=197016756 --- java/google/registry/proxy/handler/QuotaHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/java/google/registry/proxy/handler/QuotaHandler.java b/java/google/registry/proxy/handler/QuotaHandler.java index 44b949cdc..7c2c2071d 100644 --- a/java/google/registry/proxy/handler/QuotaHandler.java +++ b/java/google/registry/proxy/handler/QuotaHandler.java @@ -150,15 +150,18 @@ public abstract class QuotaHandler extends ChannelInboundHandlerAdapter { } /** - * Returns the leased token back to the token store upon connection termination. + * Returns the leased token (if available) back to the token store upon connection termination. * *

A connection with concurrent quota needs to do this in order to maintain its quota number * invariance. */ @Override public void channelInactive(ChannelHandlerContext ctx) { - checkNotNull(quotaResponse, "No quota was leased, return not possible."); - Future unusedFuture = quotaManager.releaseQuota(QuotaRebate.create(quotaResponse)); + // If no reads occurred before the connection is inactive (for example when the handshake + // is not successful), no quota is leased and therefore no return is needed. + if (quotaResponse != null) { + Future unusedFuture = quotaManager.releaseQuota(QuotaRebate.create(quotaResponse)); + } ctx.fireChannelInactive(); } }