@@ -141,15 +141,10 @@ public static AzurePersistence createPersistenceFromServicePrincipalCredentials(
141141
142142 BlobContainerClient noRetryBlobContainerClient = getBlobContainerClient (accountName , containerName , null , azureHttpRequestLoggingPolicy , clientSecretCredential );
143143
144- if (createContainer && !blobContainerClient .exists ()) {
145- blobContainerClient .create ();
146- }
147-
148- final String rootPrefixNormalized = normalizePath (rootPrefix );
149-
150- return new AzurePersistence (blobContainerClient , writeContainerClient , noRetryBlobContainerClient , rootPrefixNormalized , azureHttpRequestLoggingPolicy );
144+ return createAzurePersistence (blobContainerClient , writeContainerClient , noRetryBlobContainerClient , azureHttpRequestLoggingPolicy , rootPrefix , createContainer );
151145 }
152146
147+
153148 @ NotNull
154149 private static AzurePersistence createAzurePersistence (String connectionString , Configuration configuration , boolean createContainer ) throws IOException {
155150 return createAzurePersistence (connectionString , null , configuration .accountName (), configuration .containerName (), configuration .rootPath (), configuration .enableSecondaryLocation (), createContainer );
@@ -188,18 +183,22 @@ public static AzurePersistence createAzurePersistence(String connectionString, S
188183 noRetryBlobContainerClient = getBlobContainerClient (accountName , containerName , null , azureHttpRequestLoggingPolicy , connectionString );
189184 }
190185
191- if (createContainer && !blobContainerClient .exists ()) {
192- blobContainerClient .create ();
193- }
194-
195- final String rootPrefixNormalized = normalizePath (rootPrefix );
196-
197- return new AzurePersistence (blobContainerClient , writeBlobContainerClient , noRetryBlobContainerClient , rootPrefixNormalized , azureHttpRequestLoggingPolicy );
186+ return createAzurePersistence (blobContainerClient , writeBlobContainerClient , noRetryBlobContainerClient , azureHttpRequestLoggingPolicy , rootPrefix , createContainer );
198187 } catch (BlobStorageException e ) {
199188 throw new IOException (e );
200189 }
201190 }
202191
192+ private static AzurePersistence createAzurePersistence (BlobContainerClient blobContainerClient , BlobContainerClient writeContainerClient , BlobContainerClient noRetryBlobContainerClient , AzureHttpRequestLoggingPolicy azureHttpRequestLoggingPolicy , String rootPrefix , boolean createContainer ) {
193+ if (createContainer && !blobContainerClient .exists ()) {
194+ blobContainerClient .create ();
195+ }
196+
197+ final String rootPrefixNormalized = normalizePath (rootPrefix );
198+
199+ return new AzurePersistence (blobContainerClient , writeContainerClient , noRetryBlobContainerClient , rootPrefixNormalized , azureHttpRequestLoggingPolicy );
200+ }
201+
203202 private static BlobContainerClient getBlobContainerClientWithSas (String accountName , String containerName , RequestRetryOptions requestRetryOptions , AzureHttpRequestLoggingPolicy azureHttpRequestLoggingPolicy , String sasToken ) {
204203 BlobServiceClient blobServiceClient = blobServiceClientBuilder (accountName , requestRetryOptions , azureHttpRequestLoggingPolicy , sasToken )
205204 .buildClient ();
0 commit comments