Tartarus0zm commented on a change in pull request #13020: URL: https://github.com/apache/flink/pull/13020#discussion_r462697465
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractHandler.java ########## @@ -114,6 +115,21 @@ protected void respondAsLeader(ChannelHandlerContext ctx, RoutedRequest routedRe log.trace("Received request " + httpRequest.uri() + '.'); } + synchronized (this) { Review comment: I will fix it. ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractHandler.java ########## @@ -114,6 +115,21 @@ protected void respondAsLeader(ChannelHandlerContext ctx, RoutedRequest routedRe log.trace("Received request " + httpRequest.uri() + '.'); } + synchronized (this) { + if (terminationFuture != null) { + String errorMsg = "The handler instance for " + untypedResponseMessageHeaders.getTargetRestEndpointURL() + + " had already been closed"; + log.warn(errorMsg); + HandlerUtils.sendErrorResponse( Review comment: If we doesn’t submit a response,the client only wait for timeout. and if we do ```ctx.channel().close()``` , how about the request in flight? ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractHandler.java ########## @@ -114,6 +115,21 @@ protected void respondAsLeader(ChannelHandlerContext ctx, RoutedRequest routedRe log.trace("Received request " + httpRequest.uri() + '.'); } + synchronized (this) { + if (terminationFuture != null) { + String errorMsg = "The handler instance for " + untypedResponseMessageHeaders.getTargetRestEndpointURL() + + " had already been closed"; + log.warn(errorMsg); + HandlerUtils.sendErrorResponse( Review comment: If we doesn’t submit a response,the client only wait for timeout. and if we do ```ctx.channel().close()``` , what about the request in flight? ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractHandler.java ########## @@ -114,6 +115,21 @@ protected void respondAsLeader(ChannelHandlerContext ctx, RoutedRequest routedRe log.trace("Received request " + httpRequest.uri() + '.'); } + synchronized (this) { + if (terminationFuture != null) { + String errorMsg = "The handler instance for " + untypedResponseMessageHeaders.getTargetRestEndpointURL() + + " had already been closed"; + log.warn(errorMsg); + HandlerUtils.sendErrorResponse( Review comment: I will test ```ctx.channel().close()``` . what's your mean about ```What about catching the NullPointerException within handleException?``` ? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org