Jelajahi Sumber

ZOOKEEPER-2856: ZooKeeperSaslClient#respondToServer should log exception

See https://issues.apache.org/jira/browse/ZOOKEEPER-2856 for details.

When upstream like HBase call ZooKeeperSaslClient with security enabled, we sometimes get error in HBase logs like:
`SASL authentication failed using login context 'Client'.`
This error occures when getting SaslException in ZooKeeperSaslClient#respondToServer :
`catch (SaslException e) {`
                `LOG.error("SASL authentication failed using login context '" +`
                       ` this.getLoginContext() + "'.");`
                `saslState = SaslState.FAILED;`
                `gotLastPacket = true;`
`  }`
This error makes user confused without explicit exception message. So I think we can add exception message to the log.

The patch uses  parameterized logging to add the exception message to the log.

Author: panyuxuan <panyuxuan@cmss.chinamobile.com>

Reviewers: Michael Han <hanm@apache.org>

Closes #318 from pyx1990/ZOOKEEPER-2856
panyuxuan 8 tahun lalu
induk
melakukan
41b30a74ec

+ 1 - 1
src/java/main/org/apache/zookeeper/client/ZooKeeperSaslClient.java

@@ -361,7 +361,7 @@ public class ZooKeeperSaslClient {
                 }
                 }
             } catch (SaslException e) {
             } catch (SaslException e) {
                 LOG.error("SASL authentication failed using login context '" +
                 LOG.error("SASL authentication failed using login context '" +
-                        this.getLoginContext() + "'.");
+                        this.getLoginContext() + "' with exception: {}", e);
                 saslState = SaslState.FAILED;
                 saslState = SaslState.FAILED;
                 gotLastPacket = true;
                 gotLastPacket = true;
             }
             }