timmylicheng commented on a change in pull request #1498:
URL: https://github.com/apache/ozone/pull/1498#discussion_r516408856



##########
File path: 
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/AWSSignatureProcessor.java
##########
@@ -108,23 +109,29 @@ public void init()
 
     this.method = context.getMethod();
     String authHeader = headers.get(AUTHORIZATION_HEADER);
-    String[] split = authHeader.split(" ");
-    if (split[0].equals(AuthorizationHeaderV2.IDENTIFIER)) {
-      if (v2Header == null) {
-        v2Header = new AuthorizationHeaderV2(authHeader);
-      }
-    } else {
-      if (v4Header == null) {
-        v4Header = new AuthorizationHeaderV4(authHeader);
+    if (authHeader != null) {
+      String[] split = authHeader.split(" ");
+      if (split[0].equals(AuthorizationHeaderV2.IDENTIFIER)) {
+        if (v2Header == null) {
+          v2Header = new AuthorizationHeaderV2(authHeader);
+        }
+      } else {
+        if (v4Header == null) {
+          v4Header = new AuthorizationHeaderV4(authHeader);
+        }
+        parse();
       }
-      parse();
+    } else { // no auth header
+      v4Header = null;
+      v2Header = null;
     }
   }
 
 
-  public void parse() throws Exception {
-    StringBuilder strToSign = new StringBuilder();
+  private void parse() throws Exception {
+    Preconditions.checkNotNull(v4Header);

Review comment:
       I think so. Otherwise, v4header is still likely to throw NPE...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to