Skip to content

Commit 880ef3f

Browse files
authored
Throwing exception if blob name is passed as null (#41099)
1 parent 50f3dcd commit 880ef3f

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

sdk/storage/azure-storage-blob-cryptography/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/storage/azure-storage-blob-cryptography",
5-
"Tag": "java/storage/azure-storage-blob-cryptography_961671aec4"
5+
"Tag": "java/storage/azure-storage-blob-cryptography_8b89809d96"
66
}

sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/EncryptedFlux.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ ByteBuffer limit() is exclusive, which is why we add one to a limit if that byte
9999
EncryptedFlux(int testCase, AsyncKeyEncryptionKey key, BlobCryptographyTestBase base) throws InvalidKeyException {
100100
this.testCase = testCase;
101101
this.plainText = base.getRandomData(DOWNLOAD_SIZE - 2); // This will yield two bytes of padding... for fun.
102+
String blobName = base.generateBlobName();
102103

103104
EncryptedBlob encryptedBlob = new EncryptedBlobAsyncClient(null, "https://random.blob.core.windows.net",
104-
BlobServiceVersion.getLatest(), null, null, null, null, null, null, key, "keyWrapAlgorithm", null,
105+
BlobServiceVersion.getLatest(), null, null, blobName, null, null, null, key, "keyWrapAlgorithm", null,
105106
EncryptionVersion.V1, false)
106107
.encryptBlob(just(this.plainText)).block();
107108
this.cipherText = FluxUtil.collectBytesInByteBufferStream(encryptedBlob.getCiphertextFlux())

sdk/storage/azure-storage-blob/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/storage/azure-storage-blob",
5-
"Tag": "java/storage/azure-storage-blob_e9a4d152f3"
5+
"Tag": "java/storage/azure-storage-blob_b29c63bb55"
66
}

sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlobAsyncClientBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ protected BlobAsyncClientBase(HttpPipeline pipeline, String url, BlobServiceVers
230230
throw LOGGER.logExceptionAsError(
231231
new IllegalArgumentException("'snapshot' and 'versionId' cannot be used at the same time."));
232232
}
233+
if (blobName == null) {
234+
throw LOGGER.logExceptionAsError(new NullPointerException("'blobName' can not be set to null."));
235+
}
233236
this.azureBlobStorage = new AzureBlobStorageImplBuilder()
234237
.pipeline(pipeline)
235238
.url(url)

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public void setup() {
9090
tagValue = testResourceNamer.randomName(prefix, 20);
9191
}
9292

93+
@Test
94+
public void blobNameNull() {
95+
assertThrows(NullPointerException.class, () -> cc.getBlobClient(null));
96+
}
97+
9398
@Test
9499
public void createAllNull() {
95100
// Overwrite the existing cc, which has already been created

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public void setup() {
8585
tagValue = testResourceNamer.randomName(prefix, 20);
8686
}
8787

88+
@Test
89+
public void blobNameNull() {
90+
assertThrows(NullPointerException.class, () -> cc.getBlobClient(null));
91+
}
92+
8893
@Test
8994
public void createAllNull() {
9095
// Overwrite the existing cc, which has already been created

0 commit comments

Comments
 (0)