zentol commented on a change in pull request #11639: [FLINK-16626][runtime] Prevent REST handler from being closed more than once URL: https://github.com/apache/flink/pull/11639#discussion_r404158544
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/AbstractHandler.java ########## @@ -217,11 +223,17 @@ private void finalizeRequestProcessing(FileUploads uploadedFiles) { HttpResponseStatus.INTERNAL_SERVER_ERROR, responseHeaders); } + } @Override public final CompletableFuture<Void> closeAsync() { - return FutureUtils.composeAfterwards(closeHandlerAsync(), inFlightRequestTracker::awaitAsync); + if (isHandlerClosed.compareAndSet(false, true)) { + return FutureUtils.composeAfterwards(closeHandlerAsync(), inFlightRequestTracker::awaitAsync); + } else { + log.warn("Handler instance {} had already been closed, not allowed to close it again.", this); Review comment: Without a `toString()` implementation the reference to the handler isn't that user-friendly; I would instead suggest to use `untypedResponseMessageHeaders.getTargetRestEndpointURL`. Something along the lines of `The handler for the url ({}) was already closed, but another attempt at closing it was made.` ---------------------------------------------------------------- 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 With regards, Apache Git Services