You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by si...@apache.org on 2021/09/21 05:05:39 UTC

[pulsar] branch master updated: Fixed NPE in ProxyConnection with no auth data (#12111)

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new ea562f8f Fixed NPE in ProxyConnection with no auth data (#12111)
ea562f8f is described below

commit ea562f8f13fe887a1d0957ca066738aacf8d1265
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Mon Sep 20 22:04:44 2021 -0700

    Fixed NPE in ProxyConnection with no auth data (#12111)
    
    ### Motivation
    
    In #12057 there was a fix for missing authdata, but `AuthData.of()` is expecting a valid `byte[]` instance, empty if there are no credentials.
---
 .../src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
index 28c6083..dd814cf 100644
--- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
+++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
@@ -92,6 +92,8 @@ public class ProxyConnection extends PulsarHandler implements FutureListener<Voi
     private String proxyToBrokerUrl;
     private HAProxyMessage haProxyMessage;
 
+    private static final byte[] EMPTY_CREDENTIALS = new byte[0];
+
     enum State {
         Init,
 
@@ -315,7 +317,7 @@ public class ProxyConnection extends PulsarHandler implements FutureListener<Voi
                 return;
             }
 
-            AuthData clientData = AuthData.of(connect.hasAuthData() ? connect.getAuthData() : null);
+            AuthData clientData = AuthData.of(connect.hasAuthData() ? connect.getAuthData() : EMPTY_CREDENTIALS);
             if (connect.hasAuthMethodName()) {
                 authMethod = connect.getAuthMethodName();
             } else if (connect.hasAuthMethod()) {