This is an automated email from the ASF dual-hosted git repository.
rsivaram pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new c18463ec2d7 MINOR: Rethrow caught exception instead of wrapping into
LoginException (#16769)
c18463ec2d7 is described below
commit c18463ec2d723e46c5b4e4d71d712c1c86f0e893
Author: Philip Nee <[email protected]>
AuthorDate: Tue Aug 6 01:48:07 2024 -0700
MINOR: Rethrow caught exception instead of wrapping into LoginException
(#16769)
Reviewers: Rajini Sivaram <[email protected]>
---
.../org/apache/kafka/common/security/authenticator/LoginManager.java | 5 +++--
.../apache/kafka/common/security/authenticator/LoginManagerTest.java | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git
a/clients/src/main/java/org/apache/kafka/common/security/authenticator/LoginManager.java
b/clients/src/main/java/org/apache/kafka/common/security/authenticator/LoginManager.java
index 52373a961fc..636ee939e6d 100644
---
a/clients/src/main/java/org/apache/kafka/common/security/authenticator/LoginManager.java
+++
b/clients/src/main/java/org/apache/kafka/common/security/authenticator/LoginManager.java
@@ -63,12 +63,13 @@ public class LoginManager {
this.loginMetadata = loginMetadata;
this.login = Utils.newInstance(loginMetadata.loginClass);
loginCallbackHandler =
Utils.newInstance(loginMetadata.loginCallbackClass);
- try (AutoCloseable loginResources = this::closeResources) {
+ try {
loginCallbackHandler.configure(configs, saslMechanism,
jaasContext.configurationEntries());
login.configure(configs, jaasContext.name(),
jaasContext.configuration(), loginCallbackHandler);
login.login();
} catch (Exception e) {
- throw new LoginException(e.getMessage());
+ closeResources();
+ throw e;
}
}
diff --git
a/clients/src/test/java/org/apache/kafka/common/security/authenticator/LoginManagerTest.java
b/clients/src/test/java/org/apache/kafka/common/security/authenticator/LoginManagerTest.java
index 9a3599b5506..2d4b65e4e26 100644
---
a/clients/src/test/java/org/apache/kafka/common/security/authenticator/LoginManagerTest.java
+++
b/clients/src/test/java/org/apache/kafka/common/security/authenticator/LoginManagerTest.java
@@ -166,7 +166,7 @@ public class LoginManagerTest {
}
@Test
- public void testLoginException() throws Exception {
+ public void testShouldReThrowExceptionOnErrorLoginAttempt() throws
Exception {
Map<String, Object> config = new HashMap<>();
config.put(SaslConfigs.SASL_JAAS_CONFIG, dynamicPlainContext);
config.put(SaslConfigs.SASL_LOGIN_CLASS, Login.class);