Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aaf59af

Browse files
committedMar 7, 2023
Fix SchemaRegistryManager failure caused by apache/pulsar#19295
1 parent 5e96a19 commit aaf59af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/SchemaRegistryManager.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import java.util.Base64;
3939
import java.util.Optional;
4040
import java.util.concurrent.ExecutionException;
41+
import java.util.concurrent.TimeUnit;
42+
import java.util.concurrent.TimeoutException;
4143
import javax.naming.AuthenticationException;
4244
import lombok.AllArgsConstructor;
4345
import lombok.extern.slf4j.Slf4j;
@@ -99,8 +101,11 @@ public String authenticate(FullHttpRequest request) throws SchemaStorageExceptio
99101
throw new SchemaStorageException("Pulsar is not configured for Token auth");
100102
}
101103
try {
104+
AuthData authData = AuthData.of(password.getBytes(StandardCharsets.UTF_8));
102105
final AuthenticationState authState = authenticationProvider
103-
.newAuthState(AuthData.of(password.getBytes(StandardCharsets.UTF_8)), null, null);
106+
.newAuthState(authData, null, null);
107+
// TODO: Use the configurable timeout
108+
authState.authenticateAsync(authData).get(10, TimeUnit.SECONDS);
104109
final String role = authState.getAuthRole();
105110

106111
final String tenant;
@@ -118,7 +123,7 @@ public String authenticate(FullHttpRequest request) throws SchemaStorageExceptio
118123

119124
performAuthorizationValidation(username, role, tenant);
120125
return tenant;
121-
} catch (AuthenticationException err) {
126+
} catch (ExecutionException | InterruptedException | TimeoutException | AuthenticationException err) {
122127
throw new SchemaStorageException(err);
123128
}
124129

0 commit comments

Comments
 (0)
Please sign in to comment.