Code review comment: I think that's not enough, we should also provide an explanation why we can ignore this, because it's not simple to reason about (will add this)

Code under review:
public boolean releaseAndTryRemove(String key) throws Exception {
        checkNotNull(key, "Key in ConfigMap.");
        final AtomicReference<RetrievableStateHandle<T>> stateHandleRefer = new AtomicReference<>();
        return updateConfigMap(
                        configMap -> {
                            final String content = configMap.getData().get(key);
                            if (content != null) {
                                try {
                                    final StateHandleWithDeleteMarker<T> result =
                                            deserializeStateHandle(content);
                                    if (!result.isMarkedForDeletion()) {
                                        configMap
                                                .getData()
                                                .put(
                                                        key,
                                                        encodeStateHandle(
                                                                InstantiationUtil.serializeObject(
                                                                        result.toDeleting())));
                                    }
                                    stateHandleRefer.set(result.getInner());
                                } catch (IOException e) {
                                    LOG.warn(
                                            "Could not retrieve the state handle of {} from ConfigMap {}.",
                                            key,
                                            configMapName,
                                            e);
                                    
                                    Objects.requireNonNull(configMap.getData().remove(key));
                                }
                            }
                            return Optional.of(configMap);
                        })
                .thenCompose(
                        updated -> {
                            
                            if (stateHandleRefer.get() != null) {
                                try {
                                    stateHandleRefer.get().discardState();
                                    return updateConfigMap(
                                            configMap -> {
                                                configMap.getData().remove(key);
                                                return Optional.of(configMap);
                                            });
                                } catch (Exception e) {
                                    throw new CompletionException(e);
                                }
                            }
                            return CompletableFuture.completedFuture(updated);
                        })
                .get();
    }


Revised code:
public boolean releaseAndTryRemove(String key) throws Exception {
        checkNotNull(key, "Key in ConfigMap.");
        final AtomicReference<RetrievableStateHandle<T>> stateHandleRefer = new AtomicReference<>();
        return updateConfigMap(
                        configMap -> {
                            final String content = configMap.getData().get(key);
                            if (content != null) {
                                try {
                                    final StateHandleWithDeleteMarker<T> result =
                                            deserializeStateHandle(content);
                                    if (!result.isMarkedForDeletion()) {
                                        
                                        
                                        
                                        configMap
                                                .getData()
                                                .put(
                                                        key,
                                                        serializeStateHandle(result.toDeleting()));
                                    }
                                    stateHandleRefer.set(result.getInner());
                                } catch (IOException e) {
                                    logInvalidEntry(key, configMapName, e);
                                    
                                    
                                    Objects.requireNonNull(configMap.getData().remove(key));
                                }
                                return Optional.of(configMap);
                            }
                            return Optional.empty();
                        })
                .thenCompose(
                        updated -> {
                            if (updated && stateHandleRefer.get() != null) {
                                try {
                                    stateHandleRefer.get().discardState();
                                    return updateConfigMap(
                                            configMap -> {
                                                
                                                
                                                
                                                configMap.getData().remove(key);
                                                return Optional.of(configMap);
                                            });
                                } catch (Exception e) {
                                    throw new CompletionException(e);
                                }
                            }
                            return CompletableFuture.completedFuture(updated);
                        })
                .get();
    }