Code review comment: not particularly picky about this: but since we're now throwing on finding the decryption policy, could we just throw an exception in the for loop when we encounter it? That way we dont need to loop over all the rest of the policies if the first policy was a decryption policy?

Code under review:
private HttpPipeline getHttpPipeline() {
        
        if (httpPipeline != null) {
            List<HttpPipelinePolicy> policies = new ArrayList<>();
            
            boolean decryptionPolicyPresent = false;
            for (int i = 0; i < httpPipeline.getPolicyCount(); i++) {
                HttpPipelinePolicy currPolicy = httpPipeline.getPolicy(i);
                decryptionPolicyPresent |= currPolicy instanceof BlobDecryptionPolicy;
                policies.add(currPolicy);
            }
            
            if (!decryptionPolicyPresent) {
                policies.add(0, new BlobDecryptionPolicy(keyWrapper, keyResolver));
            } else {
                throw new IllegalArgumentException("The passed pipeline was already configured for "
                    + "encryption/decryption in a way that might conflict with the passed key information. Please "
                    + "ensure that the passed pipeline is not already configured for encryption/decryption");
            }
            return new HttpPipelineBuilder()
                .httpClient(httpPipeline.getHttpClient())
                .policies(policies.toArray(new HttpPipelinePolicy[0]))
                .build();
        }

        Configuration userAgentConfiguration = (configuration == null) ? Configuration.NONE : configuration;

        
        List<HttpPipelinePolicy> policies = new ArrayList<>();

        policies.add(new BlobDecryptionPolicy(keyWrapper, keyResolver));
        String clientName = USER_AGENT_PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
        String clientVersion = USER_AGENT_PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion");
        policies.add(new UserAgentPolicy(logOptions.getApplicationId(), clientName, clientVersion,
            userAgentConfiguration));
        policies.add(new RequestIdPolicy());
        policies.add(new AddDatePolicy());

        if (storageSharedKeyCredential != null) {
            policies.add(new StorageSharedKeyCredentialPolicy(storageSharedKeyCredential));
        } else if (tokenCredential != null) {
            BuilderHelper.httpsValidation(tokenCredential, "bearer token", endpoint, logger);
            policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint)));
        } else if (sasTokenCredential != null) {
            policies.add(new SasTokenCredentialPolicy(sasTokenCredential));
        }

        HttpPolicyProviders.addBeforeRetryPolicies(policies);
        policies.add(new RequestRetryPolicy(retryOptions));

        policies.addAll(additionalPolicies);

        HttpPolicyProviders.addAfterRetryPolicies(policies);

        policies.add(new ResponseValidationPolicyBuilder()
            .addOptionalEcho(Constants.HeaderConstants.CLIENT_REQUEST_ID)
            .addOptionalEcho(Constants.HeaderConstants.ENCRYPTION_KEY_SHA256)
            .build());

        policies.add(new HttpLoggingPolicy(logOptions));

        policies.add(new ScrubEtagPolicy());

        return new HttpPipelineBuilder()
            .policies(policies.toArray(new HttpPipelinePolicy[0]))
            .httpClient(httpClient)
            .build();
    }

Line commented on: if (!decryptionPolicyPresent) {

Revised code:
private HttpPipeline getHttpPipeline() {
        
        if (httpPipeline != null) {
            List<HttpPipelinePolicy> policies = new ArrayList<>();
            
            boolean decryptionPolicyPresent = false;
            for (int i = 0; i < httpPipeline.getPolicyCount(); i++) {
                HttpPipelinePolicy currPolicy = httpPipeline.getPolicy(i);
                if (currPolicy instanceof BlobDecryptionPolicy) {
                    throw logger.logExceptionAsError(new IllegalArgumentException("The passed pipeline was already"
                        + " configured for encryption/decryption in a way that might conflict with the passed key "
                        + "information. Please ensure that the passed pipeline is not already configured for "
                        + "encryption/decryption"));
                }
                policies.add(currPolicy);
            }
            
            policies.add(0, new BlobDecryptionPolicy(keyWrapper, keyResolver));

            return new HttpPipelineBuilder()
                .httpClient(httpPipeline.getHttpClient())
                .policies(policies.toArray(new HttpPipelinePolicy[0]))
                .build();
        }

        Configuration userAgentConfiguration = (configuration == null) ? Configuration.NONE : configuration;

        
        List<HttpPipelinePolicy> policies = new ArrayList<>();

        policies.add(new BlobDecryptionPolicy(keyWrapper, keyResolver));
        String clientName = USER_AGENT_PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
        String clientVersion = USER_AGENT_PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion");
        policies.add(new UserAgentPolicy(logOptions.getApplicationId(), clientName, clientVersion,
            userAgentConfiguration));
        policies.add(new RequestIdPolicy());

        HttpPolicyProviders.addBeforeRetryPolicies(policies);
        policies.add(new RequestRetryPolicy(retryOptions));

        policies.add(new AddDatePolicy());

        if (storageSharedKeyCredential != null) {
            policies.add(new StorageSharedKeyCredentialPolicy(storageSharedKeyCredential));
        } else if (tokenCredential != null) {
            BuilderHelper.httpsValidation(tokenCredential, "bearer token", endpoint, logger);
            policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint)));
        } else if (sasTokenCredential != null) {
            policies.add(new SasTokenCredentialPolicy(sasTokenCredential));
        }

        policies.addAll(additionalPolicies);

        HttpPolicyProviders.addAfterRetryPolicies(policies);

        policies.add(new ResponseValidationPolicyBuilder()
            .addOptionalEcho(Constants.HeaderConstants.CLIENT_REQUEST_ID)
            .addOptionalEcho(Constants.HeaderConstants.ENCRYPTION_KEY_SHA256)
            .build());

        policies.add(new HttpLoggingPolicy(logOptions));

        policies.add(new ScrubEtagPolicy());

        return new HttpPipelineBuilder()
            .policies(policies.toArray(new HttpPipelinePolicy[0]))
            .httpClient(httpClient)
            .build();
    }