diff --git a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java index 021f4e468fec..d4d7e0a246ee 100644 --- a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java +++ b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java @@ -907,11 +907,11 @@ public boolean requesterPays(String bucketName) { // instead of true/false, this method returns true/null. Boolean isRP = storage.get(bucketName).requesterPays(); return isRP != null && isRP.booleanValue(); - } catch (StorageException sex) { - if (sex.getCode() == 400 && sex.getMessage().contains("Bucket is requester pays")) { + } catch (StorageException ex) { + if (ex.getCode() == 400 && ex.getMessage().contains("Bucket is requester pays")) { return true; } - throw sex; + throw ex; } } diff --git a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java index 28f7dc6f2c5b..b99b914d4435 100644 --- a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java +++ b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/it/ITGcsNio.java @@ -166,8 +166,8 @@ public void testFileExistsRequesterPaysNoUserProject() throws IOException { // fails because we must pay for every access, including metadata. Files.exists(path); Assert.fail("It should have thrown an exception."); - } catch (StorageException sex) { - assertIsRequesterPaysException("testFileExistsRequesterPaysNoUserProject", sex); + } catch (StorageException ex) { + assertIsRequesterPaysException("testFileExistsRequesterPaysNoUserProject", ex); } } @@ -196,8 +196,8 @@ public void testCantCreateWithoutUserProject() throws IOException { // fails Files.write(path, "I would like to write".getBytes()); Assert.fail("It should have thrown an exception."); - } catch (StorageException sex) { - assertIsRequesterPaysException("testCantCreateWithoutUserProject", sex); + } catch (StorageException ex) { + assertIsRequesterPaysException("testCantCreateWithoutUserProject", ex); } } @@ -218,8 +218,8 @@ public void testCantReadWithoutUserProject() throws IOException { // fails Files.readAllBytes(path); Assert.fail("It should have thrown an exception."); - } catch (StorageException sex) { - assertIsRequesterPaysException("testCantReadWithoutUserProject", sex); + } catch (StorageException ex) { + assertIsRequesterPaysException("testCantReadWithoutUserProject", ex); } } @@ -269,8 +269,8 @@ private void innerTestCantCopyWithoutUserProject( description, hex.getMessage() .contains("Bucket is requester pays bucket but no user project provided")); - } catch (StorageException sex) { - assertIsRequesterPaysException(description, sex); + } catch (StorageException ex) { + assertIsRequesterPaysException(description, ex); } } @@ -317,11 +317,11 @@ public void testAutodetectWhenNotRequesterPays() throws IOException { ""); } - private void assertIsRequesterPaysException(String message, StorageException sex) { - Assert.assertEquals(message, sex.getCode(), 400); + private void assertIsRequesterPaysException(String message, StorageException ex) { + Assert.assertEquals(message, ex.getCode(), 400); Assert.assertTrue( message, - sex.getMessage().contains("Bucket is requester pays bucket but no user project provided")); + ex.getMessage().contains("Bucket is requester pays bucket but no user project provided")); } // End of tests related to the "requester pays" feature