Skip to content

Commit b5578fb

Browse files
authored
Enabling v2 stack as the default for Event Hubs (#43725)
* Enabling v2 stack as the default for Event Hubs * Update V2StackSupport to enable v2 by default
1 parent 2cbcdf6 commit b5578fb

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features Added
66

7+
Setting the v2 stack as the default. ([43725](https://github.com/Azure/azure-sdk-for-java/pull/43725))
8+
79
### Breaking Changes
810

911
- Do not remove `x-opt-partition-key` message annotation when publishing events.

sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/V2StackSupport.java

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class V2StackSupport {
3535
private static final ConfigurationProperty<Boolean> V2_STACK_PROPERTY
3636
= ConfigurationPropertyBuilder.ofBoolean(V2_STACK_KEY)
3737
.environmentVariableName(V2_STACK_KEY)
38-
.defaultValue(false)
38+
.defaultValue(true)
3939
.shared(true)
4040
.build();
4141
private final AtomicReference<Boolean> v2StackFlag = new AtomicReference<>();
@@ -62,7 +62,7 @@ final class V2StackSupport {
6262
* @return true if the clients should use the v2 stack.
6363
*/
6464
boolean isV2StackEnabled(Configuration configuration) {
65-
return isOptedIn(configuration, V2_STACK_PROPERTY, v2StackFlag);
65+
return !isOptedOut(configuration, V2_STACK_PROPERTY, v2StackFlag);
6666
}
6767

6868
/**
@@ -113,33 +113,6 @@ private boolean isOptedOut(Configuration configuration, ConfigurationProperty<Bo
113113
return choiceFlag.get();
114114
}
115115

116-
private boolean isOptedIn(Configuration configuration, ConfigurationProperty<Boolean> configProperty,
117-
AtomicReference<Boolean> choiceFlag) {
118-
final Boolean flag = choiceFlag.get();
119-
if (flag != null) {
120-
return flag;
121-
}
122-
123-
final String propName = configProperty.getName();
124-
final boolean isOptedIn;
125-
if (configuration != null) {
126-
isOptedIn = configuration.get(configProperty);
127-
} else {
128-
assert !CoreUtils.isNullOrEmpty(propName);
129-
if (!CoreUtils.isNullOrEmpty(System.getenv(propName))) {
130-
isOptedIn = "true".equalsIgnoreCase(System.getenv(propName));
131-
} else if (!CoreUtils.isNullOrEmpty(System.getProperty(propName))) {
132-
isOptedIn = "true".equalsIgnoreCase(System.getProperty(propName));
133-
} else {
134-
isOptedIn = false;
135-
}
136-
}
137-
if (choiceFlag.compareAndSet(null, isOptedIn)) {
138-
logger.verbose("Selected configuration {}={}", propName, isOptedIn);
139-
}
140-
return choiceFlag.get();
141-
}
142-
143116
ReactorConnectionCache<EventHubReactorAmqpConnection> createConnectionCache(ConnectionOptions connectionOptions,
144117
Supplier<String> eventHubNameSupplier, MessageSerializer serializer, Meter meter,
145118
boolean useSessionChannelCache) {

0 commit comments

Comments
 (0)