hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject hadoop git commit: HADOOP-14609. NPE in AzureNativeFileSystemStore.checkContainer() if StorageException lacks an error code. Contributed by Steve Loughran
Date Wed, 28 Jun 2017 21:22:29 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 a5ae7c0ca -> ba7689739


HADOOP-14609. NPE in AzureNativeFileSystemStore.checkContainer() if StorageException lacks
an error code. Contributed by Steve Loughran

(cherry picked from commit 990aa34de23c625163745ebc338483065d955bbe)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ba768973
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ba768973
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ba768973

Branch: refs/heads/branch-2
Commit: ba76897392b686ee7ee9e2120c14311bdefb706c
Parents: a5ae7c0
Author: Mingliang Liu <liuml07@apache.org>
Authored: Wed Jun 28 14:18:59 2017 -0700
Committer: Mingliang Liu <liuml07@apache.org>
Committed: Wed Jun 28 14:20:44 2017 -0700

----------------------------------------------------------------------
 .../hadoop/fs/azure/AzureNativeFileSystemStore.java       | 10 +++++-----
 .../org/apache/hadoop/fs/azure/SelfRenewingLease.java     |  4 ++--
 .../apache/hadoop/fs/azure/TestBlobDataValidation.java    |  6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba768973/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/AzureNativeFileSystemStore.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/AzureNativeFileSystemStore.java
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/AzureNativeFileSystemStore.java
index 60f4c97..eeaa7e6 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/AzureNativeFileSystemStore.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/AzureNativeFileSystemStore.java
@@ -1194,8 +1194,8 @@ public class AzureNativeFileSystemStore implements NativeFileSystemStore
{
         container.downloadAttributes(getInstrumentedContext());
         currentKnownContainerState = ContainerState.Unknown;
       } catch (StorageException ex) {
-        if (ex.getErrorCode().equals(
-            StorageErrorCode.RESOURCE_NOT_FOUND.toString())) {
+        if (StorageErrorCode.RESOURCE_NOT_FOUND.toString()
+            .equals(ex.getErrorCode())) {
           currentKnownContainerState = ContainerState.DoesntExist;
         } else {
           throw ex;
@@ -1596,7 +1596,7 @@ public class AzureNativeFileSystemStore implements NativeFileSystemStore
{
       if (t != null && t instanceof StorageException) {
         StorageException se = (StorageException) t;
         // If we got this exception, the blob should have already been created
-        if (!se.getErrorCode().equals("LeaseIdMissing")) {
+        if (!"LeaseIdMissing".equals(se.getErrorCode())) {
           throw new AzureException(e);
         }
       } else {
@@ -2427,7 +2427,7 @@ public class AzureNativeFileSystemStore implements NativeFileSystemStore
{
       // 2. It got there after one-or-more retries THEN
       // we swallow the exception.
       if (e.getErrorCode() != null &&
-          e.getErrorCode().equals("BlobNotFound") &&
+          "BlobNotFound".equals(e.getErrorCode()) &&
           operationContext.getRequestResults().size() > 1 &&
           operationContext.getRequestResults().get(0).getException() != null) {
         LOG.debug("Swallowing delete exception on retry: {}", e.getMessage());
@@ -2478,7 +2478,7 @@ public class AzureNativeFileSystemStore implements NativeFileSystemStore
{
       Throwable t = e.getCause();
       if(t != null && t instanceof StorageException) {
         StorageException se = (StorageException) t;
-        if(se.getErrorCode().equals(("LeaseIdMissing"))){
+        if ("LeaseIdMissing".equals(se.getErrorCode())){
           SelfRenewingLease lease = null;
           try {
             lease = acquireLease(key);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba768973/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/SelfRenewingLease.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/SelfRenewingLease.java
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/SelfRenewingLease.java
index 76098f3..00d5e99 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/SelfRenewingLease.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/SelfRenewingLease.java
@@ -82,7 +82,7 @@ public class SelfRenewingLease {
         // Throw again if we don't want to keep waiting.
         // We expect it to be that the lease is already present,
         // or in some cases that the blob does not exist.
-        if (!e.getErrorCode().equals("LeaseAlreadyPresent")) {
+        if (!"LeaseAlreadyPresent".equals(e.getErrorCode())) {
           LOG.info(
             "Caught exception when trying to get lease on blob "
             + blobWrapper.getUri().toString() + ". " + e.getMessage());
@@ -119,7 +119,7 @@ public class SelfRenewingLease {
     try {
       blobWrapper.getBlob().releaseLease(accessCondition);
     } catch (StorageException e) {
-      if (e.getErrorCode().equals("BlobNotFound")) {
+      if ("BlobNotFound".equals(e.getErrorCode())) {
 
         // Don't do anything -- it's okay to free a lease
         // on a deleted file. The delete freed the lease

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba768973/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobDataValidation.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobDataValidation.java
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobDataValidation.java
index c40b7b5..ea17b62 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobDataValidation.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestBlobDataValidation.java
@@ -20,9 +20,9 @@ package org.apache.hadoop.fs.azure;
 
 import static org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.KEY_CHECK_BLOCK_MD5;
 import static org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.KEY_STORE_BLOB_MD5;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeNotNull;
 
@@ -130,8 +130,8 @@ public class TestBlobDataValidation {
       }
       StorageException cause = (StorageException)ex.getCause();
       assertNotNull(cause);
-      assertTrue("Unexpected cause: " + cause,
-          cause.getErrorCode().equals(StorageErrorCodeStrings.INVALID_MD5));
+      assertEquals("Unexpected cause: " + cause,
+          StorageErrorCodeStrings.INVALID_MD5, cause.getErrorCode());
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message