Skip to content

Commit

Permalink
[Broker] Remove unnecessary futures; fix comment (apache#11776)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljmarshall authored and ciaocloud committed Oct 16, 2021
1 parent 00072ae commit 9a9790f
Showing 1 changed file with 2 additions and 16 deletions.
Expand Up @@ -382,8 +382,6 @@ private CompletableFuture<Boolean> isTopicOperationAllowed(TopicName topicName,

private CompletableFuture<Boolean> isTopicOperationAllowed(TopicName topicName, String subscriptionName,
TopicOperation operation) {
CompletableFuture<Boolean> isProxyAuthorizedFuture;
CompletableFuture<Boolean> isAuthorizedFuture;
if (service.isAuthorizationEnabled()) {
if (authenticationData == null) {
authenticationData = new AuthenticationDataCommand("", subscriptionName);
Expand All @@ -395,20 +393,8 @@ private CompletableFuture<Boolean> 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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9a9790f

Please sign in to comment.