Github user dhruve commented on a diff in the pull request:
https://github.com/apache/spark/pull/18407#discussion_r123765067
--- Diff:
common/network-common/src/main/java/org/apache/spark/network/sasl/SparkSaslServer.java
---
@@ -187,14 +188,30 @@ public void handle(Callback[] callbacks) throws
IOException, UnsupportedCallback
/* Encode a byte[] identifier as a Base64-encoded string. */
public static String encodeIdentifier(String identifier) {
Preconditions.checkNotNull(identifier, "User cannot be null if SASL is
enabled");
- return
Base64.encode(Unpooled.wrappedBuffer(identifier.getBytes(StandardCharsets.UTF_8)))
- .toString(StandardCharsets.UTF_8);
+ return getBase64EncodedString(identifier);
}
/** Encode a password as a base64-encoded char[] array. */
public static char[] encodePassword(String password) {
Preconditions.checkNotNull(password, "Password cannot be null if SASL
is enabled");
- return
Base64.encode(Unpooled.wrappedBuffer(password.getBytes(StandardCharsets.UTF_8)))
- .toString(StandardCharsets.UTF_8).toCharArray();
+ return getBase64EncodedString(password).toCharArray();
+ }
+
+ /** Return a Base64-encoded string. */
+ private static String getBase64EncodedString (String str) {
+ ByteBuf byteBuf = null, encodedByteBuf = null;
--- End diff --
Okay. The order of releasing the buffers does not matter. We check for the
byteBuf first just incase if we hit an exception while trying to acquire it, we
know we don't need to check encodedByteBuf.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]