Skip to content

ZOOKEEPER-4947: Close clients after authentication failure - #2443

Open
1fanwang wants to merge 1 commit into
apache:masterfrom
1fanwang:fix-zookeeper-4947-auth-failed-close
Open

ZOOKEEPER-4947: Close clients after authentication failure#2443
1fanwang wants to merge 1 commit into
apache:masterfrom
1fanwang:fix-zookeeper-4947-auth-failed-close

Conversation

@1fanwang

Copy link
Copy Markdown

A client that fails SASL authentication stays in AUTH_FAILED when the caller closes it. The close guard treats every non-alive state as already closed, so it skips the connection shutdown and leaves the client threads running.

This narrows the early return to CLOSED. Authentication failures now use the normal disconnect path, while repeated close calls remain idempotent.

Related:

Testing

$ SOURCE=zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
$ git checkout 7af463e0fd -- "$SOURCE"
$ JAVA_HOME=$(/usr/libexec/java_home -v 21) mvn -pl zookeeper-server -am test \
    '-Dtest=SaslAuthFailTest#testBadSaslAuthNotifiesWatch' \
    -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
expected: <CLOSED> but was: <AUTH_FAILED>
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

$ git checkout 5a201d633f -- "$SOURCE"
$ JAVA_HOME=$(/usr/libexec/java_home -v 21) mvn -pl zookeeper-server -am test \
    -Dtest=SaslAuthFailTest \
    -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

ZooKeeper.close() treated AUTH_FAILED clients as already closed and skipped prompt shutdown of their connection threads.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant