From 9a9790f76924c3537ede8ab44675c1cc5d4ae6a5 Mon Sep 17 00:00:00 2001 From: Michael Marshall Date: Fri, 27 Aug 2021 02:12:50 -0500 Subject: [PATCH] [Broker] Remove unnecessary futures; fix comment (#11776) --- .../pulsar/broker/service/ServerCnx.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java index 7d02e6a2910bcb..c84836216a398c 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java @@ -382,8 +382,6 @@ private CompletableFuture isTopicOperationAllowed(TopicName topicName, private CompletableFuture isTopicOperationAllowed(TopicName topicName, String subscriptionName, TopicOperation operation) { - CompletableFuture isProxyAuthorizedFuture; - CompletableFuture isAuthorizedFuture; if (service.isAuthorizationEnabled()) { if (authenticationData == null) { authenticationData = new AuthenticationDataCommand("", subscriptionName); @@ -395,20 +393,8 @@ private CompletableFuture isTopicOperationAllowed(TopicName topicName, } return isTopicOperationAllowed(topicName, operation); } else { - isProxyAuthorizedFuture = CompletableFuture.completedFuture(true); - isAuthorizedFuture = CompletableFuture.completedFuture(true); + return CompletableFuture.completedFuture(true); } - return isProxyAuthorizedFuture.thenCombine(isAuthorizedFuture, (isProxyAuthorized, isAuthorized) -> { - if (!isProxyAuthorized) { - log.warn("OriginalRole {} is not authorized to perform operation {} on topic {}, subscription {}", - originalPrincipal, operation, topicName, subscriptionName); - } - if (!isAuthorized) { - log.warn("Role {} is not authorized to perform operation {} on topic {}, subscription {}", - authRole, operation, topicName, subscriptionName); - } - return isProxyAuthorized && isAuthorized; - }); } @Override @@ -638,7 +624,7 @@ private State doAuthentication(AuthData clientData, if (authState.isComplete()) { // Authentication has completed. It was either: - // 1. the 1st time the authentication process was done, in which case we'll + // 1. the 1st time the authentication process was done, in which case we'll send // a `CommandConnected` response // 2. an authentication refresh, in which case we need to refresh authenticationData