diff --git a/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md b/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md index 1f76ff2a1746..87d057470dc1 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md +++ b/sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features Added +Setting the v2 stack as the default. ([43725](https://github.com/Azure/azure-sdk-for-java/pull/43725)) + ### Breaking Changes - Do not remove `x-opt-partition-key` message annotation when publishing events. diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/V2StackSupport.java b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/V2StackSupport.java index 09a9f44d7e96..dbd2488f1217 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/V2StackSupport.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/V2StackSupport.java @@ -35,7 +35,7 @@ final class V2StackSupport { private static final ConfigurationProperty V2_STACK_PROPERTY = ConfigurationPropertyBuilder.ofBoolean(V2_STACK_KEY) .environmentVariableName(V2_STACK_KEY) - .defaultValue(false) + .defaultValue(true) .shared(true) .build(); private final AtomicReference v2StackFlag = new AtomicReference<>(); @@ -62,7 +62,7 @@ final class V2StackSupport { * @return true if the clients should use the v2 stack. */ boolean isV2StackEnabled(Configuration configuration) { - return isOptedIn(configuration, V2_STACK_PROPERTY, v2StackFlag); + return !isOptedOut(configuration, V2_STACK_PROPERTY, v2StackFlag); } /** @@ -113,33 +113,6 @@ private boolean isOptedOut(Configuration configuration, ConfigurationProperty configProperty, - AtomicReference choiceFlag) { - final Boolean flag = choiceFlag.get(); - if (flag != null) { - return flag; - } - - final String propName = configProperty.getName(); - final boolean isOptedIn; - if (configuration != null) { - isOptedIn = configuration.get(configProperty); - } else { - assert !CoreUtils.isNullOrEmpty(propName); - if (!CoreUtils.isNullOrEmpty(System.getenv(propName))) { - isOptedIn = "true".equalsIgnoreCase(System.getenv(propName)); - } else if (!CoreUtils.isNullOrEmpty(System.getProperty(propName))) { - isOptedIn = "true".equalsIgnoreCase(System.getProperty(propName)); - } else { - isOptedIn = false; - } - } - if (choiceFlag.compareAndSet(null, isOptedIn)) { - logger.verbose("Selected configuration {}={}", propName, isOptedIn); - } - return choiceFlag.get(); - } - ReactorConnectionCache createConnectionCache(ConnectionOptions connectionOptions, Supplier eventHubNameSupplier, MessageSerializer serializer, Meter meter, boolean useSessionChannelCache) {